Skip to main content

Overview

The configuration API provides functions to manage persistent storage of user preferences. All settings are stored using the conf library in a local configuration file.

Location Management

getStoredLocation

Retrieve the stored location from configuration.
StoredLocation

setStoredLocation

Save location data to configuration.
StoredLocation
required
All fields are optional. You can update individual fields without overwriting others.

hasStoredLocation

Check if a valid location is stored.
boolean
true if either city/country or coordinates are stored

Prayer Settings

getStoredPrayerSettings

Get calculation method, school, and timezone settings.
StoredPrayerSettings

setStoredMethod

Set the calculation method.
number
required
Calculation method ID (0-23). See prayer times methods

setStoredSchool

Set the Asr calculation school.
number
required
School ID: 0 for Shafi (standard) or 1 for Hanafi (later Asr)

setStoredTimezone

Set the timezone override.
string
IANA timezone string (e.g., “Asia/Karachi”, “Europe/London”)

Ramadan Date Settings

getStoredFirstRozaDate

Get the configured first roza date (for custom Ramadan tracking).
string | undefined
ISO date string (YYYY-MM-DD) or undefined if not set

setStoredFirstRozaDate

Set the first roza date for custom Ramadan tracking.
string
required
ISO date string in YYYY-MM-DD format
The date must be in ISO format (YYYY-MM-DD). Invalid formats will throw an error.

clearStoredFirstRozaDate

Remove the stored first roza date.

Bulk Operations

saveAutoDetectedSetup

Save location and apply recommended settings based on country.
GeoLocation
required
Location data from guessLocation()
This function:
  1. Saves city, country, coordinates
  2. Saves timezone
  3. Applies recommended calculation method for the country
  4. Applies recommended school (Hanafi/Shafi) for the country

clearRamadanConfig

Clear all stored configuration.
This deletes all stored settings including location, method, school, timezone, and first roza date.

Recommendations System

getRecommendedMethod

Get the recommended calculation method for a country.
string
required
Country name (case-insensitive)
number | null
Recommended method ID or null if no recommendation

getRecommendedSchool

Get the recommended Asr school for a country.
string
required
Country name (case-insensitive)
number
0 for Shafi (standard) or 1 for Hanafi (later Asr)

Hanafi Countries

The following countries default to Hanafi school:
  • Pakistan
  • Bangladesh
  • India
  • Afghanistan
  • Turkey
  • Iraq
  • Syria
  • Jordan
  • Palestine
  • Central Asian countries (Kazakhstan, Uzbekistan, Tajikistan, etc.)
All other countries default to Shafi school.

shouldApplyRecommendedMethod

Check if a recommended method should be applied based on current and recommended values.
number
required
Current method ID
Recommended method ID
boolean
True if recommendation should be applied

shouldApplyRecommendedSchool

Check if a recommended school should be applied based on current and recommended values.
number
required
Current school (0=Shafi, 1=Hanafi)
Recommended school
boolean
True if recommendation should be applied

applyRecommendedSettingsIfUnset

Apply recommended settings only if user hasn’t customized them.
string
required
Country name

Usage Examples

Complete Setup Flow

Manual Configuration

Update Individual Settings

Custom Ramadan Dates

Configuration Location

Configuration is stored in:
  • Linux: ~/.config/ramadan-cli/config.json
  • macOS: ~/Library/Preferences/ramadan-cli/config.json
  • Windows: %APPDATA%\ramadan-cli\Config\config.json
You can override the config directory using the RAMADAN_CLI_CONFIG_DIR environment variable:

TypeScript Types