daylight icon indicating copy to clipboard operation
daylight copied to clipboard

bug: Incorrect Sunrise/Sunset Date for Timezones Ahead of UTC

Open fa0311 opened this issue 11 months ago • 0 comments

Description

When the timezone is ahead of UTC, the retrieved sunrise and sunset times are calculated for the incorrect date, causing a one-day shift.

Steps To Reproduce

  1. Input a datetime in a timezone that is ahead of UTC (e.g., Asia/Tokyo (JST)).
  2. Example: Provide January 1st, 00:00 JST.
  3. Internally, this is converted to December 31st, 15:00 UTC.
  4. The time component is then discarded, and only the date is used for sunrise/sunset calculation.
  5. As a result, the calculation is performed for December 31st instead of January 1st.

Expected Behavior

The sunrise and sunset times should be calculated for the intended local date (January 1st in this example).

Screenshots

...

Additional Context

https://github.com/bluefireteam/daylight/blob/3.1.0/lib/src/daylight.dart#L157-L158

fa0311 avatar Mar 12 '25 05:03 fa0311