Getting Started
This content is for v1.0.0. Switch to the latest version for up-to-date documentation.
Getting Started
Section titled “Getting Started”Install
Section titled “Install”pip install al-falakYour first calculation
Section titled “Your first calculation”from datetime import datetimefrom alfalak import PrayerTimes, CalculationMethod
# Coordinates for Raleigh, NCcoordinates = (35.7750, -78.6336)today = datetime.now()
prayer_times = PrayerTimes( coordinates, today, CalculationMethod.NORTH_AMERICA,)
print(f"Fajr: {prayer_times.fajr.strftime('%H:%M')}")print(f"Sunrise: {prayer_times.sunrise.strftime('%H:%M')}")print(f"Dhuhr: {prayer_times.dhuhr.strftime('%H:%M')}")print(f"Asr: {prayer_times.asr.strftime('%H:%M')}")print(f"Maghrib: {prayer_times.maghrib.strftime('%H:%M')}")print(f"Isha: {prayer_times.isha.strftime('%H:%M')}")Using a Coordinates object
Section titled “Using a Coordinates object”from alfalak import Coordinates, PrayerTimes, CalculationMethod
coords = Coordinates(latitude=35.7750, longitude=-78.6336)prayer_times = PrayerTimes(coords, datetime.now(), CalculationMethod.MUSLIM_WORLD_LEAGUE)Using custom parameters
Section titled “Using custom parameters”from alfalak import PrayerTimes, CalculationParameters
params = CalculationParameters( fajr_angle=18, isha_angle=18, isha_interval=90, # Isha = Maghrib + 90 minutes)prayer_times = PrayerTimes( coordinates, datetime.now(), calculation_parameters=params,)Timezone conversion
Section titled “Timezone conversion”from zoneinfo import ZoneInfo
london = ZoneInfo("Europe/London")prayer_times = PrayerTimes( (51.5074, -0.1278), datetime.now(), CalculationMethod.MOON_SIGHTING_COMMITTEE, time_zone=london,)Next steps
Section titled “Next steps”- Calculation Methods — compare all 11 methods
- API Reference — full API documentation
- CLI Usage — command-line interface