Algorithms

Test data for the calculations an app does on the device, checked against each authority's own published values.

Sunrise, magnetic declination, grid references and bearings are pure functions: the same input always gives the same answer. So the best way to know an implementation is right is a thorough set of test cases from an authority. This site publishes those cases, and the rules for reading them. It has no code. It grades implementations and says whether each passes.

10 published · Swift passes 10 of 10 · TypeScript passes 9 of 10


Magnetic declinationWMM2025, NOAA and BGS

137 cases →
field · noaa-table-3
latitudeInDegrees
-80
longitudeInDegrees
240
heightInKilometers
0
decimalYear
2025
expected +4 more
magneticDeclinationInDegrees
68.78
inclinationInDegrees
-72
northIntensityInNanoteslas
6117.5
eastIntensityInNanoteslas
15751.9
downIntensityInNanoteslas
-52022.5
Longitude 240 is −120: grid variation is declination plus longitude, wrapped to −180 to 180.

Declination, inclination and field strength for a place and date.

112 published 20 reference

UTM and MGRSNGA's UTM and MGRS

1694 cases →
toUtm · edge-to-utm-norway-32v
latitudeInDegrees
60
longitudeInDegrees
5
expected +1 more
zone
32
hemisphere
"north"
eastingInMeters
276979.926401
northingInMeters
6658157.202407
convergenceInDegrees
-3.4655153412295
Norway: at 60° N, 5° E is zone 32, not 31.

Grid references both ways, grid convergence, and typed coordinates parsed.

1691 reference

BearingsGreat circle on a sphere, FM 3-25.26 and Bowditch

824 cases →
formatBearing · hand-format-degrees-359-6
bearingInDegrees
359.6
angleUnit
"degrees"
expected
bearingText
"000°"
Round, then wrap: 359.6° is 000°, never 360°.

Distance and bearing, degrees and mils, compass points, true, magnetic and grid north.

6 published 615 reference 190 hand

Astronomical timeMeeus, Astronomical Algorithms

231 cases →
julianDay · usno-julian-day-julian-last-day
instantUtc
"1582-10-04T23:59:59Z"
expected
julianDay
2299160.499988
1582-10-04 in the Julian calendar is followed by 1582-10-15 in the Gregorian.

Julian day, ΔT, sidereal time, and a sky position as azimuth and altitude.

166 published 44 reference

SunMeeus, Astronomical Algorithms

631 cases →
events · usno-events-alert-2026-06-21
latitudeInDegrees
82.5018
longitudeInDegrees
-62.3481
startUtc
"2026-06-21T00:00:00Z"
windowInHours
24
expected +6 more
riseUtc
null
setUtc
null
transitUtc
"2026-06-21T16:11:00Z"
civilDawnUtc
null
civilDuskUtc
null
Midnight sun: no rise or set, always up, and a transit.

Rise, set, transit, the three twilights, azimuth and altitude.

607 published 17 reference

MoonMeeus, Astronomical Algorithms

768 cases →
events · usno-events-vancouver-2026-09-21
latitudeInDegrees
49.2827
longitudeInDegrees
-123.1207
startUtc
"2026-09-21T00:00:00Z"
windowInHours
24
expected
riseUtc
null
setUtc
"2026-09-21T07:58:00Z"
transitUtc
"2026-09-21T03:55:00Z"
isAlwaysUp
false
isAlwaysDown
false
No moonrise in this UTC day: riseUtc is null, not the next day's.

Rise, set, transit, azimuth and altitude, illumination, phase, the dates of the next phases, libration and the axis's angle.

604 published 155 reference

Tide predictionHarmonic method, Schureman's SP 98 as NOAA runs it

148 cases →
nextExtremes · noaa-next-extremes-seattle-2031-06-03-2100
constituents
[34 constituents]
startUtc
"2031-06-03T21:00:00Z"
expected
highUtc
"2031-06-04T00:10:00Z"
highHeightInMeters
1.206
lowUtc
"2031-06-04T05:16:00Z"
lowHeightInMeters
0.014

The height at any instant, and the next high and low, from a station's harmonic constants.

140 published

Time zonesIANA zone names on timezone-boundary-builder 2026f

1836 cases →
timeZone · edge-urumqi
latitudeInDegrees
43.8256
longitudeInDegrees
87.6168
expected
timeZoneNames
["Asia/Shanghai","Asia/Urumqi"]
nearby
[]
Xinjiang, where timezone-boundary-builder overlaps Asia/Shanghai and Asia/Urumqi on purpose: both.

The IANA time zone names at a point, on land or at sea.

1830 reference

Star positionsMeeus, Astronomical Algorithms

449 cases →
position · usno-position-vancouver-2026-vega
rightAscensionInHours
18.61564
declinationInDegrees
38.7836
properMotionEastInArcsecondsPerYear
0.202
properMotionNorthInArcsecondsPerYear
0.286
expected
azimuthInDegrees
295.029503
altitudeInDegrees
30.982306

A catalogue star's azimuth and altitude, and refraction at any altitude.

311 published 129 reference

PlanetsVSOP87 and Meeus; Mallama and Hilton for magnitude

278 cases →
position · usno-position-vancouver-2026-saturn
planet
"saturn"
latitudeInDegrees
49.2827
longitudeInDegrees
-123.1207
instantUtc
"2026-09-29T08:00:00Z"
expected
azimuthInDegrees
170.705655
altitudeInDegrees
42.489022

Mercury to Saturn's azimuth and altitude, magnitude, phase and elongation.

127 published 145 reference

How it works

Implementations

Each is a repo of its own, and the code isn’t public yet. Each one’s CI grades it against the current test data on every push and whenever the data changes, the same way in every language; the format has the contract. Each shows whether it passes, fails or is incomplete for every algorithm, the commit graded and the compiler that built it. New test cases can turn an implementation red; that’s the prompt to fix it.

ImplementationStatus
gshaw/algorithms-swiftSwift Passes · 10 of 10 pass62d540c · Swift version 6.4.2
gshaw/algorithms-typescriptTypeScript Incomplete · 9 of 10 passfff2755 · Node 26.12.1

Licence

The test data is CC0: copy it into any project with no strings. One exception: time zones is ODbL, since its zones come from OpenStreetMap, so it needs their credit. The site and its tools are MIT. Each source’s own terms are listed with its data.