UNPKG

@observerly/astrometry

Version:

observerly's lightweight, zero-dependency, type safe astrometry library written in Typescript for calculating the position of celestial objects in the sky.

54 lines (53 loc) 1.32 kB
import { convertEquatorialToHorizontal as g } from "./coordinates.js"; import { getSolarEquatorialCoordinate as m } from "./sun.js"; var n; (function(t) { t.Night = "Night", t.Astronomical = "Astronomical", t.Nautical = "Nautical", t.Civil = "Civil", t.Day = "Day"; })(n || (n = {})); const h = (t) => { switch (!0) { case t < -18: return n.Night; case t < -12: return n.Astronomical; case t < -6: return n.Nautical; case t < 0: return n.Civil; default: return n.Day; } }, C = (t, i, D = { stepSeconds: 10 }) => { const { stepSeconds: w = 10 } = D, s = new Date(t.getFullYear(), t.getMonth(), t.getDate()), c = new Date(s.getTime() + 864e5); let e = new Date(s.getTime()); const a = [], f = m(e), { alt: p } = g(e, i, f); let o = h(p), r = new Date(e.getTime()); for (; e < c; ) { const v = m(e), { alt: N } = g(e, i, v), l = h(N); if (l !== o) { const u = new Date(e.getTime()); a.push({ name: o, interval: { from: r, to: u } }), o = l, r = u; } e = new Date(e.getTime() + w * 1e3); } return a.push({ name: o, interval: { from: r, to: c } }), a; }; export { n as Twilight, C as getTwilightBandsForDay }; //# sourceMappingURL=twilight.js.map