Testing Taxi

Intelligent Assistant for Testers


Testing Durations with Time Zones

Durations are part of almost every application around us. We use durations for time clocks, hourly billing and more. But, there are tonnes of little edge cases hiding within a simple duration. It’s not as easy as subtracting the two dates and getting a duration, or doing simple math two durations to get a new duration.

Daylight Savings (DST)

Daylight savings time is one of the major sources of bugs in duration calculations. Some countries use DST to keep the hours somewhat consistent with the position of the sun during the day. So, how does it work?

In the spring, the time zone “springs forward” and removes an hour from the clock. The hour we remove is the 2am hour on the day that we move forward. So it goes: 1:58am, 1:59am, 3:00am, 3:01am…

In the fall, the time zone “falls backward” and adds an hour to the clock. Rather than “adding” an hour, we replay the hour of 1am. So it goes: 1:58am, 1:59am, 1:00am, 1:01am…1:59am, 2:00am…

So, you can see where this can cause issues in duration calculations. Adding and removing hours is not the sort of thing that simple arithmetic like time_end – time_start would like to deal with.

Duration Playground

Grab the “Adjust Time” slider or click on the clock and see how the hours and durations change.