Sunrise & Sunset
Location
About the Calculation
The calculations use the JavaScript library SunCalc by Vladimir Agafonkin, which is based on Jean Meeus' standard work Astronomical Algorithms (2nd edition, 1998).
1. Julian Date & Epoch J2000.0
All calculations internally use the Julian Date (JD) — a continuous day count from 1 January 4713 BC. The reference point is the epoch J2000.0 (1 January 2000, 12:00 UTC = JD 2,451,545.0). The number of days since J2000.0 is called d.
2. Sun Position
The ecliptic longitude of the Sun is computed via the mean anomaly:
M = 357.5291° + 0.98560028° × d (mean anomaly)
C = 1.9148·sin(M) + 0.0200·sin(2M) + 0.0003·sin(3M) (equation of centre)
λ = M + C + 180° + 102.9372° (ecliptic longitude)
The Sun's declination (its angle to the celestial equator) follows:
sin(δ) = sin(λ) · sin(23.4397°) (23.4397° = axial tilt)
3. Solar Noon
Solar noon at a given longitude:
J_transit = 2,451,545.5 + λ_geo/360 + 0.0009
+ 0.0053·sin(M) − 0.0069·sin(2λ)
where λ_geo is the observer's geographic longitude.
4. Hour Angle & Sunrise Time
Sunrise and sunset occur when the Sun reaches a certain altitude h above the horizon. From the spherical triangle zenith–pole–Sun:
cos(ω₀) = (sin(h) − sin(φ)·sin(δ)) / (cos(φ)·cos(δ))
φ is the geographic latitude, ω₀ the hour angle of rise or set. Sunrise time is solar noon − ω₀/360, sunset is solar noon + ω₀/360.
5. Altitude Corrections by Event
The threshold h varies by event:
| Event | Altitude h | Explanation |
|---|---|---|
| Sunrise / sunset | −0.833° | Top of Sun at horizon + atmospheric refraction (~0.57°) + solar radius (~0.27°) |
| Civil twilight | −6° | Bright enough to read outdoors; horizon visible |
| Nautical twilight | −12° | Horizon still recognisable for navigation |
| Astronomical twilight | −18° | Sky fully dark |
Accuracy
The model is an approximation accurate to ±1 minute for practical purposes. High-precision astronomical calculations (e.g. eclipse predictions) require more elaborate perturbation methods. Atmospheric refraction at the horizon also depends on air pressure and temperature — these are approximated here with standard values (1013 hPa, 10 °C).