casvanluijtelaar / paged_vertical_calendar

A simple paginated framework for implementing calendar based interfaces.
Apache License 2.0
39 stars 33 forks source link

fix: ignore time when adding days #35

Closed Snorlax8 closed 1 year ago

Snorlax8 commented 1 year ago

Hi! We noticed an issue regarding the display of the calendar weeks. This is related to daylight saving time (we are based in Chile, where we set our clocks back the first week of April). Here is proof of the issue when compiling the provided example:

Simulator Screen Shot - iPhone 14 Pro Max - 2023-02-28 at 15 24 07

This is a problem that occurs across years. The previous example was of the year 2023, and the following is of 2025:

Simulator Screen Shot - iPhone 14 Pro Max - 2023-02-28 at 15 28 52

We found that the main error was that the first week of April was broken apart into two different weeks. On closer inspection, it turned out that the reason for this was our local daylight saving time change, which occurs on the first Saturday of April. On the _lastDayofWeek method, when doing the following operation:

firstDayOfWeek.add(Duration(days: restOfWeek))

instead of returning the correct date at 00:00, it returns the previous day at 23:00, because during that week we turn our clocks back one hour. Our proposed solution handles this by using a new method to add days that makes sure to just add the correct number of days and doesn't make time adjustments. By using this method, the problem is solved:

Simulator Screen Shot - iPhone 14 Pro Max - 2023-02-28 at 15 39 07

casvanluijtelaar commented 1 year ago

please merge the latest master to resolve analyzer issues