pub fn twilight(
kind: Twilight,
night_of: OffsetDateTime,
site: &Location,
) -> TwilightOutcomeExpand description
Dusk and dawn instants for the night whose solar lower culmination is
nearest night_of, at the darkness level kind.
Matches astroplan’s twilight instants within ±60 s (the Sun’s altitude changes ~1° per 4 minutes at mid-latitudes; the 0.01° solar-position accuracy contributes only a few seconds).
use skymath::{twilight, Location, Twilight, TwilightOutcome};
use time::OffsetDateTime;
let site = Location::parse("+52 05 32", "+004 18 27", 6.0)?;
match twilight(Twilight::Astronomical, OffsetDateTime::now_utc(), &site) {
TwilightOutcome::Night { dusk, dawn } => println!("dark {dusk} to {dawn}"),
TwilightOutcome::NeverDark => println!("never astronomically dark tonight"),
TwilightOutcome::AlwaysDark => println!("dark around the clock"),
}