Offline Sun and Moon astronomy for TypeScript and Swift
Almanac 0.1.0
Release Sky
Almanac 0.1.0 is the first release: offline Sun and Moon astronomy for TypeScript and Swift, with one behavior in both ports and no network access or runtime data files.
sunPositionandmoonPositiongive geocentric apparent right ascension, declination, and distance.sunAltAzandmoonAltAzgive refracted topocentric altitude and azimuth.sunEventsfinds sunrise, sunset, civil, nautical, and astronomical twilight, and transit within a window.moonEventsfinds moonrise and moonset from the Moon's upper limb.moonIlluminationreports the illuminated fraction, phase angle, phase, and waxing state, andsearchMoonPhasesfinds new, first-quarter, full, and last-quarter moons.nextLunarEclipsereturns the kind, peak, magnitudes, and contact times of the next lunar eclipse, andlunarEclipseVisibilityreports which contacts an observer can see.- Every function covers 1950 through 2100 and raises a typed out-of-range error outside that interval. The functions share names across both ports, with Swift argument labels. The algorithms are translated from Astronomy Engine by Don Cross.
Both ports are tested against the same external fixtures and a cross-port parity corpus, with these tolerances:
| Quantity | Tolerance | Evidence |
|---|---|---|
| Sun and Moon position | 1′ | JPL Horizons, 1,839 samples each across 1950–2100 |
| Sun distance | 1e-4 AU | JPL Horizons |
| Moon distance | 70 km | JPL Horizons |
| Rise, set, twilight, and phase times | 60 s | USNO rise and set grid, 693 USNO moon phases |
| Lunar eclipse peaks and magnitudes | 60 s, 0.03 | All 344 eclipses in the Espenak catalog, 1950–2100 |
| Lunar eclipse contacts | 60 s | NASA contact tables for four eclipses |
Event searches scale with window length: a full 151-year window takes about 68 s in TypeScript and 44 s in a Swift release build, so run long searches off the main thread. Validation includes 80 TypeScript tests, 84 Swift release tests, and the shared fixture and parity checks.
npm install @openwaters/almanac@0.1.0
.package(url: "https://github.com/openwatersio/almanac.git", exact: "0.1.0")
Changes: #1.