When working with date, time and timezone, things often seems easy at the beginning. However, the truth is, it is a lot more complicated.
Daylight saving is an interesting topic and even more interesting when you have to design software with this in mind.
Take Australia as an example. According to Business Victoria:
The 2017-2018 daylight saving period ended on Sunday 1 April, when clocks went backwards one hour at 3 am.
The 2018-2019 daylight saving period will commence in Victoria on Sunday 7 October 2018, when clocks will go forward one hour at 2 am. The conclusion of this period in 2019 is Sunday 7 April, when clocks will go backwards one hour at 3 am.
There is a reason why daylight saving happens when most of us is sleeping, it can cause a lot of headache. When you weak up that day and feel not fully recharged, yeah it is indeed because someone had stolen one hour from that night.
Let’s use moment.js to add 30 mins in a loop to show what exactly happened.
moment().add('30','minutes');
moment().format('YYYY-MM-DD HH:mm:ss');
Enter Day Light Saving Clock Forward 1 hour at 2:00AM
2019-10-07 01:00:00
2019-10-07 01:30:00
-.-!
2019-10-07 03:00:00
2019-10-07 03:30:00
Yeah when it supposed to be 2:00 AM, it shows 3:00AM as result. and you only added 30 mins. So that day only has 23 hours. If the booking software you designed is using this loop to generate 24 hour slot for each day. you will find the last slot of that day (the 24th hour) is actually the next day.
Exit Day Light Saving Clock Backward 1 hour at 3:00 AM
2019-04-07 01:00:00
2019-04-07 01:30:00
2019-04-07 02:00:00
2019-04-07 02:30:00
2019-04-07 02:00:00
2019-04-07 02:30:00
2019-04-07 03:00:00
2019-04-07 03:30:00
when it supposed to be 3:00AM, it shows 2:00AM. Yeah, 2:30AM + 30mins is 2:00AM. So that day has 25 hours.
In real lift that would cause many issue already. see if you have a book a meeting with your doctor on 2019-10-07 02:30:00AM. you will be surprised that this is a time do not exist! If you have worked a night shift from 2019-04-07 02:00AM to 3:00AM, that shift is actually 2 hours!