DEV Community

Fagner Brack
Fagner Brack

Posted on • Originally published at fagnerbrack.com on

The Wall of DST Hell

The real code comment of a real company


The cover of an album from Noise in Paradisum

// The Wall of DST Hell
// --------------------
//
// Edge case 1:
// DST has caused an event from the previous day (6AM - 23PM)
// to block the entire next day.
// Make sure offset is changed in this code when DST changes.
// Right now this is hard coded to Sydney offset.
// Edge case 2 (24 March 2020):
// On March 2020, a customer in Sydney complained that on
// April 7 2020 whole day was blocked when they only had
// an "All Day" event on the previous day.
// The system was querying Google Calendar with the
// offset +11:00 for a date (April 7) where the
// offset is +10:00.
// When querying April 07 on a date before DST ended,
// the event from the previous day was coming in the list.
// That's why this function now hooks the offset to Luxon so
// that when we query a given date, we query using the correct
// offset relative to that date, not the one we're
// currently in.
// We're keeping it hardcoded to Australia/Sydney since all our
// customers are based in Sydney.
// Edge case 3 (07 September 2021):
// A customer based on Brisbane had their calendar blocked in
// the next day from an "All Day" event of the previous
// day when the previous day is under the effect of
// DST in Sydney.
// This happened because the "zone" was hard-coded to
// 'Australia/Sydney' but the customer calendar and company
// config were on 'Australia/Brisbane'.
// This issue was observed on 07 September and happened from
// the dates of 3 October (Sunday) to 4 October 2021 (Monday),
// which is the start of DST where the clocks forward 1
// hours for all states of Australia except... Brisbane.
// The cause for this bug was tricky to find because first we
// noticed the whole October month was locked for
// the only two calendars of the customer. The thing
// is they put one "All Day" event every 2 days, as they
// work one day in one location then another day in
// the other location. Therefore, the whole month became
// locked from October 03.
// I've changed to get the "zone" from the company
// config instead of hard code it to 'Australia/Sydney'.
// I hope this to be the last entry to the wall.
Enter fullscreen mode Exit fullscreen mode

I hope this to be the last entry to the wall.

We all hope so…

Thanks for reading. If you have feedback, contact me on Twitter, LinkedIn or Github.

Top comments (0)