Prayer Times Calculation
Astronomical Functions
Equation of Time

Equation of Time (EoT)

The Equation of Time (EoT) is a parameter that describes the difference between the true solar time and the mean solar time. The mean solar time is the time that would be shown by a perfect clock moving uniformly, while the true solar time is based on the actual position of the Sun in the sky.

Formula used

y=tan2(ϵ2×π180)y = \tan^2 \Big(\frac{\epsilon}{2} \times \frac{\pi}{180}\Big)

term_1=ysin(2LSπ180)\text{term}\_1 = y \cdot \sin \Big(2 \cdot \frac{\textit{LS} \cdot \pi}{180}\Big)

term_2=2esin(MAπ180)\text{term}\_2 = -2 \cdot e \cdot \sin\Big(\frac{\textit{MA} \cdot \pi}{180}\Big)

term_3=4eysin(MAπ180)cos(2LSπ180)\text{term}\_3 = 4 \cdot e \cdot y \cdot \sin \Big(\frac{\textit{MA} \cdot \pi}{180}\Big) \cdot \cos\Big(2 \cdot \frac{\textit{LS} \cdot \pi}{180}\Big)

term_4=0.5y2sin(4LSπ180)\text{term}\_4 = -0.5 \cdot y^2 \cdot \sin \Big(4 \cdot \frac{\textit{LS} \cdot \pi}{180}\Big)

term_5=1.25e2sin(2MAπ180)\text{term}\_5 = -1.25 \cdot e^2 \cdot \sin\Big(2 \cdot \frac{\textit{MA} \cdot \pi}{180}\Big)

EoT=4×180π×(term_1+term_2+term_3+term_4+term_5)\textit{EoT} = 4 \times \frac{180}{\pi} \times \left( \text{term}\_1 + \text{term}\_2 + \text{term}\_3 + \text{term}\_4 + \text{term}\_5 \right)

Where:

ϵ\epsilon = Obliquity Correction (degrees)

LS\textit{LS} = Geometric Mean Longitude of the Sun

ee = Eccentricity of Earth's Orbit

MA\textit{MA} = Geometric Mean Anomaly of the Sun

LS\textit{LS} = Geometric Mean Longitude of the Sun

Code Implementation

../prayertimes2025//pt_engine/astro_helpers/equation_of_time.py

import math
from .sun_parameters import geom_mean_long_sun, geomc_mean_anom_sun
from .earth_parameters import mean_obliquity_of_ecliptic, obliquity_correction, eccentricity_of_earth_orbit
from .julian_date import julian_date
from .julian_century import julian_century

def _var_y(obliq_corr_deg: float) -> float:
    """Calculate the variable y, based on the Obliquity Correction."""
    return math.tan(math.radians(obliq_corr_deg / 2)) ** 2

def equation_of_time( 
    year: int, 
    month: int, 
    day: int, 
    hours: float, 
    utc_offset: float
) -> float:
   
    # Calculate the Julian Date
    j_d = julian_date(year, month, day, hours, utc_offset)
    
    # Calculate the Julian Century
    j_c = julian_century(j_d)
    
    # Calculate the necessary intermediate values
    gmls = geom_mean_long_sun(j_c)
    gmas = geomc_mean_anom_sun(j_c)
    eeo = eccentricity_of_earth_orbit(j_c)
    
    epsilon_0 = mean_obliquity_of_ecliptic(j_c)
    obliq_corr = obliquity_correction(epsilon_0, j_c)
    y_value = _var_y(obliq_corr)
    
    # Calculate the Equation of Time (EoT)
    term1 = y_value * math.sin(2 * math.radians(gmls))
    term2 = -2 * eeo * math.sin(math.radians(gmas))
    term3 = 4 * eeo * y_value * math.sin(math.radians(gmas)) * math.cos(2 * math.radians(gmls))
    term4 = -0.5 * y_value * y_value * math.sin(4 * math.radians(gmls))
    term5 = -1.25 * eeo * eeo * math.sin(2 * math.radians(gmas))
    
    eot = 4 * math.degrees(term1 + term2 + term3 + term4 + term5)
    
    return eot
↗ View in github