You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
getTimes returns a sunrise/sunset on the next day for certain lat/long #174
Using getTimes for some coordinates (close to a TZ border) and times close to but before midnight appears to produce an incorrect sunset time that is on the following day.
changed the title [-]getTimes returns a sunset on the next day for certain lat/long[/-][+]getTimes returns a sunrise/sunset on the next day for certain lat/long[/+]on Nov 23, 2023
This is fixed in SunCalc v2.0.0. It's the same root cause as #11/#161/#185: the old getTimes bucketed the date by the nearest solar transit, so a time late in the local evening (your 23:40, which is 2022-04-14T15:40Z) got pushed onto the next day's events. v2 anchors to the UTC solar day containing the instant, so the result no longer depends on time-of-day.
Verified against your exact inputs:
getTimes(2022-04-14T23:40:15.817+08:00, -14.41499, 128.52524)
sunrise UTC 2022-04-13T21:32:28Z → 14/04/2022 05:32 Perth
sunset UTC 2022-04-14T09:19:52Z → 14/04/2022 17:19 Perth ✓
Both events now fall on April 14 as expected. Closing as resolved.
Activity
[-]getTimes returns a sunset on the next day for certain lat/long[/-][+]getTimes returns a sunrise/sunset on the next day for certain lat/long[/+]iankim-dev commentedon Feb 21, 2025
same issue
mourner commentedon Jun 18, 2026
This is fixed in SunCalc v2.0.0. It's the same root cause as #11/#161/#185: the old
getTimesbucketed the date by the nearest solar transit, so a time late in the local evening (your 23:40, which is2022-04-14T15:40Z) got pushed onto the next day's events. v2 anchors to the UTC solar day containing the instant, so the result no longer depends on time-of-day.Verified against your exact inputs:
Both events now fall on April 14 as expected. Closing as resolved.