Calculating Fajr and Ishaa times
Overview
Similarily to the way we calculated Shurouq and Maghrib times, the calculaiton of Fajr and Ishaa is about converting the solar altitude angle at which Fajr and Ishaa are usually perceived to a corresponding time.
For Fajr, we are interested in the time when the Sun is 19º degrees below the horizon, and for Ishaa, we are interested in the time when the Sun is 18º degrees below the horizon.
These degrees stem from observations made by muslim astronomers for generations, since the 4th Hijri century until today.
Code Implementation
../prayertimes2025//pt_engine/compute_times/compute_fajr_ishaa_time.py
from datetime import datetime, timedelta
from pt_engine.astro_helpers import hour_angle_for_solar_altitude
def compute_fajr_ishaa_time(pt_type: str, reference_angle: float, date: datetime, utc_offset: float, latitude: float, longitude: float, declination: float, eot: float, ) -> datetime:
# Calculate Solar Noon Time
standard_meridian = 15 * utc_offset
local_time_correction = (standard_meridian - longitude) / 15
solar_noon = timedelta(hours=12) + timedelta(hours=local_time_correction) - timedelta(minutes=eot)
# Calculate Hour Angle H for the determined reference_angle
hour_angle = hour_angle_for_solar_altitude(latitude, declination, reference_angle)
prayer_time = None
if pt_type == 'fajr':
# Calculate Fajr Time
prayer_time = datetime.combine(date, datetime.min.time()) + solar_noon - timedelta(hours=hour_angle / 15)
elif pt_type == 'ishaa':
# Calculate Ishaa Time
prayer_time = datetime.combine(date, datetime.min.time()) + solar_noon + timedelta(hours=hour_angle / 15)
else:
raise ValueError("Invalid type. Must be 'fajr' or 'ishaa'")
return prayer_time
↗ View in github