Check whether the Sun is up
Almanac 0.9.0
Release Sky
Almanac 0.9.0 provides an instantaneous sunrise-based day/night decision in TypeScript, Swift, and Kotlin.
sunIsUp(time, observer, heightAboveGroundM = 0)returns whether the Sun’s upper limb clears the modeled horizon. It uses the same changing solar radius, standard refraction convention, topocentric geometry, and optional horizon dip assunEventssunrise and sunset.- Polar day and night work without an event search or a calendar-day choice. The helper preserves the existing date, observer, and eye-height validation. Exact equality with the horizon target returns
false. - The cookbook shows display-mode recipes in all three languages, explains eye height versus elevation, and leaves refresh timing and missing-position handling to the application. The astronomical model does not account for terrain, clouds, or eclipses.
Tests cover independent USNO sunrise/set evidence, midnight sun, polar night, raised horizons, and a grazing polar sunrise where a fixed threshold on refracted altitude reports night. Cross-port parity checks the boolean exactly. The release workflow verifies all three suites, Kotlin coverage and source consumption, and independent SwiftPM and packed npm consumers before publishing with provenance.
npm install @openwaters/almanac@0.9.0
import { sunIsUp } from '@openwaters/almanac';
const mode = sunIsUp(new Date(), observer) ? 'day' : 'night';
.package(url: "https://github.com/openwatersio/almanac.git", exact: "0.9.0")
Kotlin consumers can pin the v0.9.0 source checkout using the installation guide. No Maven artifact is published.
Day/night helper and cookbook: #75. Release preparation: #76.