sunAltitudefunction
The Sun's altitude over a place at a moment, in degrees (geometric: the centre of the disc, no refraction).
Import it
import { sunAltitude } from "@johnmorrisdotca/hoshi-stars/tonight";
Definition
function sunAltitude(observer: Observer, when: When): number
Parameters
| Name | Type | Description |
|---|---|---|
observer | Observer | Latitude north and longitude east in degrees. |
when | When | The moment, a |
Returns
number
Degrees above the horizon, negative when the Sun is down.
Examples
import { sunAltitude } from "@johnmorrisdotca/hoshi-stars/tonight";
// midnight in Vancouver in November: the Sun is far below the horizon
console.log(sunAltitude({ latitude: 49.28, longitude: -123.12 }, Date.UTC(2026, 10, 8, 8)) < -18);trueWhat it prints (run when this page was built)