Skip to content

Solar Calculations

TimeNow uses the highest-accuracy open solar position algorithms available.

NREL Solar Position Algorithm (SPA)

The backend implements the NREL SPA (Solar Position Algorithm) developed by the National Renewable Energy Laboratory. This is the same algorithm used by:

  • The US Naval Observatory
  • Major Islamic prayer time apps (MuslimPro, Azan, etc.)
  • HOMER Energy simulation software

Accuracy

Accuracy depends on which implementation is used. The NOAA Solar Calculator uses simplified equations, not NREL SPA. TimeNow's Scala backend uses the full NREL SPA with IERS corrections.

Scala Backend (NREL SPA + Orekit + IERS)

Quantity Accuracy Notes
Solar zenith/azimuth ±0.0003° (1″) Topocentric, VSOP87 + 63-term nutation
Equation of time ±0.1 seconds GAST from IERS UT1−UTC
Sunrise / sunset ±2 seconds Iterative solve + distance-aware semidiameter
Solar noon ±0.1 seconds GAST-derived
Refraction Bennett >5°; Saemundsson <5° T/P corrected

Valid for years 1962–present+1 year (IERS EOP data coverage). Theoretical SPA range is −2000 to +6000, but UT1 corrections degrade outside IERS coverage.

C / Rust Daemons (NOAA Simplified)

Quantity Accuracy Notes
Solar zenith/azimuth ±0.01° Simplified NOAA polynomials
Equation of time ±0.5 minutes 3-term equation of center
Sunrise / sunset ±30 seconds Single iterate, fixed 90.833°
Solar noon ±30 seconds From EoT
Refraction Bennett only T/P corrected

Valid for years 2005–2050 (Delta-T polynomial). Outside this range, error grows ~1 s/decade.

Reference

Ibrahim Reda and Afshin Andreas, "Solar Position Algorithm for Solar Radiation Applications," Solar Energy, vol. 76, no. 5, pp. 577-589, 2004. NREL/TP-560-34302


IERS Earth Orientation Parameters (EOP)

In addition to the NREL SPA, TimeNow applies corrections from the International Earth Rotation and Reference Systems Service (IERS).

What IERS Corrects

Correction Description Magnitude
ΔUT1 Difference between UTC and UT1 (rotation-based time) ±0.9 s (by definition)
Polar motion (xp, yp) Wobble of Earth's rotation axis ±0.5" (arcseconds)
LOD Length of day variations ±1 ms/day

Why This Matters

The IERS corrections ensure that solar noon calculations are accurate to ±1 second rather than the ±15-second accuracy of SPA alone.

For prayer times, this improves Fajr/Isha accuracy — critical for communities near the precision boundary between calculation methods.

Data Source

IERS Bulletin A — published weekly at https://www.iers.org/IERS/EN/Publications/Bulletins/bulletins.html

TimeNow fetches EOP data on startup and caches it locally.


Equation of Time

The equation of time is the difference between true solar time and mean solar time. It arises from two effects:

  1. Earth's orbital eccentricity — Earth moves faster at perihelion (January) than aphelion (July), causing the Sun to appear to move faster or slower along the ecliptic.

  2. Obliquity of the ecliptic — Earth's axis is tilted 23.44° relative to its orbital plane, causing the Sun's right ascension to change at a non-uniform rate.

The combined equation of time ranges from −16 minutes (early November) to +14 minutes (mid-February).

solar_time = mean_solar_time + equation_of_time
civil_solar_offset = utc_offset_in_minutes - longitude/15 * 60 + equation_of_time

Civil-Solar Offset Formula

civil_solar_offset_min = (UTC_offset_h × 60) - (longitude × 4)

Where longitude × 4 converts degrees to minutes of time (360° = 24h = 1440 min).

Example — Kashgar (39.9°N, 76.0°E, UTC+8):

civil_solar_offset_min = (8 × 60) - (76.0 × 4)
                       = 480 - 304
                       = +176 minutes

Civil noon is 176 minutes (2h 56m) ahead of solar noon — one of Earth's largest structural civil-solar misalignments.


Implementation

The backend is written in Scala using the Orekit astrodynamics library for the SPA algorithm and IERS corrections.

  • Library: Orekit (Apache 2.0)
  • Framework: Play Framework (Apache 2.0)
  • Reference: NREL SPA (Reda & Andreas 2004)