Date Pick Fix and demo

by Fran T

Version 1 (May 15, 2022)

Download (5 downloads)

There's unfortunately a problem with the Date Pick block when an initial time is used with the Calendar style. The natural assumption is that by specifying Now for the initial date, today's date would be selected. However, if the local time on the device is within the time zone offset to Greenwich Mean Time (UTC), the calendar selects the GMT date instead of the local date.

For example, the West Coast of the USA is at GMT - 8 hours. When the local (standard) time reaches 4pm (1600), the calendar incorrectly selects tomorrow's date, and any date picked from then until local midnight shows as the next day when used later as the initial date for the Date Pick block.

The fix works by adding or subtracting a day if the local date differs from the GMT date. The direction is determined by whether the local time zone is ahead of or behind Greenwich Mean Time. All of the code is contained in the single Date Pick block in the Bug Fix flow here, with the rest of the blocks being to demonstrate and test it. For your own flows, you only need to copy block #2.

To test it yourself, you have to change the time on your device, and possibly the region and time zone depending on how deep you want to go. Here's how to test within your own time zone:

1) With the device date the same as the date in GMT, the calendar should default to today's date
2) After picking a date and it being shown again, your chosen date should remain as the initial date
3) Wait or change the device time so that it's still today in your time zone, but tomorrow in GMT (or vice-versa); the initial and selected dates should still be today or the date you choose

Compare the results of the above steps with the Bug Demo and Bug Fix flows.