@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.
3 lines (2 loc) • 1.19 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./coordinates.cjs"),u=require("./sun.cjs");exports.Twilight=void 0;(function(t){t.Night="Night",t.Astronomical="Astronomical",t.Nautical="Nautical",t.Civil="Civil",t.Day="Day"})(exports.Twilight||(exports.Twilight={}));const h=t=>{switch(!0){case t<-18:return exports.Twilight.Night;case t<-12:return exports.Twilight.Astronomical;case t<-6:return exports.Twilight.Nautical;case t<0:return exports.Twilight.Civil;default:return exports.Twilight.Day}},f=(t,a,w={stepSeconds:10})=>{const{stepSeconds:T=10}=w,r=new Date(t.getFullYear(),t.getMonth(),t.getDate()),l=new Date(r.getTime()+864e5);let e=new Date(r.getTime());const n=[],m=u.getSolarEquatorialCoordinate(e),{alt:D}=g.convertEquatorialToHorizontal(e,a,m);let i=h(D),o=new Date(e.getTime());for(;e<l;){const d=u.getSolarEquatorialCoordinate(e),{alt:v}=g.convertEquatorialToHorizontal(e,a,d),s=h(v);if(s!==i){const c=new Date(e.getTime());n.push({name:i,interval:{from:o,to:c}}),i=s,o=c}e=new Date(e.getTime()+T*1e3)}return n.push({name:i,interval:{from:o,to:l}}),n};exports.getTwilightBandsForDay=f;
//# sourceMappingURL=twilight.cjs.map