The math

How Sun actually computes the sun

Every time in Sun — sunrise, sunset, solar noon, twilight, golden hour — comes from the same reference algorithm: NOAA's Solar Calculator, itself a spreadsheet form of Jean Meeus' Astronomical Algorithms. No API, no network call, no third-party service — the same handful of equations run locally on your phone, and the same ones run right here in your browser to draw the calculator below.

The five numbers it actually needs

  1. Julian day. A continuous day-count since 4713 BC, so the math never has to think in months or leap years — just a real number that increases steadily. This alone is why leap years and century boundaries (2000 was a leap year, 2100 won't be) fall out correct without special-casing.
  2. Solar declination. How far the sun sits above or below the celestial equator today — the number that actually drives the seasons, computed from the Earth's 23.4° axial tilt and where it is in its yearly orbit.
  3. The equation of time. Clock noon and solar noon rarely agree, by up to about 16 minutes — a combination of the Earth's elliptical (not circular) orbit and its tilted axis, both baked into one correction in minutes.
  4. Hour angle. Given your latitude and today's declination, the angle the sun needs to travel from solar noon to reach a given altitude — this is what actually produces a rise and set time, or reveals that there isn't one (polar day or polar night).
  5. Atmospheric refraction. Light bends slightly as it passes through the atmosphere near the horizon, so "sunrise" is defined at 0.833° below the geometric horizon, not exactly at it — without this, official sunrise and sunset would each be off by about two minutes.

Put together, these five numbers answer almost everything Sun shows: sunrise and sunset (the sun crossing 90.833° from vertical), the three grades of twilight (civil at 96°, nautical at 102°, astronomical at 108°), solar noon and solar midnight, and the sun's live altitude and compass direction at any moment.

Try it — any place, any day

Sunrise
Solar noon
Sunset
Day length
Golden hour (AM)
Golden hour (PM)

Why compute it, not fetch it

A lookup API means a service that can rate-limit you, go down, or start charging — for a quantity that's genuinely just arithmetic. Sun computes everything the same way this page does: locally, from these five numbers, with no dependency on anything staying online. It's also verifiable — every value on this page and in the app can be checked against NOAA's own published reference tables at gml.noaa.gov/grad/solcalc.