Method

How sunrise times are calculated: our method, sources and validation

· ~8 min read

Every time on this site — from the calculator to the city tables — comes from one small JavaScript module we wrote ourselves, implementing formulas published by the NOAA Global Monitoring Laboratory solar calculator. This page discloses exactly what we compute, from what sources, and how closely the results match official national almanacs. We think a light-planning site should show its work.

Key takeaways

  • We implement NOAA’s public-domain solar-position series (equations from Meeus’ Astronomical Algorithms as published by NOAA) in assets/js/solar.js — no black boxes, no server calls.
  • NOAA states these formulas are accurate to about one minute for latitudes between ±72°; observed times vary with atmospheric conditions.
  • We validated against two official sources: the Hong Kong Observatory Almanac 2026 and Taiwan’s CWA 2026 Taipei table. Across 43 published events: 36 matched to the minute, worst deviation 3 minutes.
  • DST rules for US/EU/AU cities are hardcoded IANA-style rules, verified for 2026–2027; HK, Taipei, Tokyo and Singapore never observe DST.

The recipe, step by step

Sunrise time is not read from a database — it is solved from geometry. Here is the pipeline our engine runs for a requested date and place:

  1. Date to Julian day. The calendar date becomes a Julian day number, the continuous day count astronomers use.
  2. Solar coordinates. From the number of Julian centuries since J2000.0, NOAA’s series give the sun’s geometric mean longitude, mean anomaly, equation of center, true and apparent longitude, and the obliquity of the ecliptic — all standard polynomial expansions.
  3. Declination and equation of time. Those give the sun’s declination (how far north or south of the equator it appears) and the equation of time (the offset between sundial time and clock time, up to ±16 minutes across the year).
  4. Solar noon. Local solar noon in UTC = 720 − 4×longitude − equation of time, refined in a second pass. Add the time-zone offset (checking DST rules at that instant) for clock time.
  5. The sunrise equation. With latitude φ and declination δ, solve cos H = (cos 90.833° − sin φ sin δ) / (cos φ cos δ) for the hour angle H. Sunrise = solar noon − 4H minutes; sunset = noon + 4H. The 90.833° zenith target folds in the sun’s 16′ radius and 34′ of standard atmospheric refraction — the same convention official almanacs use, so "sunrise" means the moment the sun’s upper edge appears on a sea-level horizon.
  6. Two-pass refinement. Exactly as NOAA’s reference implementation, we recompute declination and equation of time at the estimated event time and solve again.
  7. Bands for twilight and magic hours. The same equation with different target elevations: −6° civil, −12° nautical, −18° astronomical twilight; −4°…+6° golden hour; −6°…−4° blue hour (definitions vary).

Sources

Validation: every spot-check, disclosed

On 2026-11-16 we compared our engine’s output against every cleanly-readable published value above, covering solstices, equinoxes and arbitrary dates spread across the year. “—” marks cells the official PDF render made unverifiable at digit level (we dropped those rather than guess; the pattern across adjacent dates is consistent). Δ is engine minus official, in minutes:

Engine vs official published values, 2026 dates. HKO = Hong Kong (22.30°N 114.17°E, UTC+8); CWA = Taipei (25.03°N 121.51°E, UTC+8).
SourceDate 2026SunriseSunsetSolar noon
OfficialOursΔOfficialOursΔOfficialOursΔ
HKO2026-03-2006:2806:28+0m18:3618:34−2m12:3212:31−1m
HKO2026-06-2105:4005:40+0m19:1019:10+0m12:2612:25−1m
HKO2026-09-2306:1306:12−1m18:1918:19+0m12:1612:16+0m
HKO2026-12-2106:5806:58+0m17:4417:44+0m—12:21—
HKO2026-03-0106:4506:45+0m18:2418:27+3m12:3512:36+1m
HKO2026-03-3106:1706:17+0m18:3818:38+0m12:2812:28+0m
HKO2026-09-3006:1406:14+0m18:1218:12+0m12:1312:14+1m
HKO2026-12-0106:4606:46+0m17:3817:38+0m12:1212:12+0m
HKO2026-12-3107:0207:02+0m—17:50—12:2612:26+0m
CWA2026-03-2005:5805:58+0m18:0518:05+0m—12:02—
CWA2026-06-2105:0505:05+0m18:4718:47+0m—11:56—
CWA2026-09-2305:4305:43+0m17:5017:50+0m—11:47—
CWA2026-12-2106:3406:34+0m17:0917:09+0m—11:52—
CWA2026-01-0106:3906:39+0m17:1617:16+0m—11:57—
CWA2026-07-0405:0905:09+0m18:4818:48+0m—11:58—
CWA2026-10-1005:5005:50+0m17:3217:32+0m—11:41—
CWA2026-12-1006:2806:28+0m17:0517:05+0m—11:46—

These checks run automatically: node tests.mjs executes all of them (plus equation-of-time anchors, solstice declinations, DST boundary tests and a DOM-shim test of the calculator) and fails the build if any deviation exceeds ±3 minutes.

Known limitations — the honest part

Related reading