mourner / suncalc

A tiny JavaScript library for calculating sun/moon positions and phases.
BSD 2-Clause "Simplified" License
3.08k stars 413 forks source link

getTimes() returns invalid Date for some fields #170

Closed dzakaTarik closed 1 year ago

dzakaTarik commented 1 year ago
SunCalc.getTimes( 
    new Date(1684365873000),
    -73.688566659788151, 
     18.128286340044944
  )

This call returns an object which has invalid Date in some fields (sunrise, sunset among others). I inspected the reason, and saw that sometimes function hourAngle returns NaN because Math.acos is called with input outside of range [-1,1].

dzakaTarik commented 1 year ago

Lat / Long were in wrong order in input. Order above represents some point on Antarctica so I guess this behaviour is expected.