Testing Taxi

Intelligent Assistant for Testers

Navigation

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.

What this bug can look like

Sometimes in the spring, incorrect reports may register an extra hour than expected. e.g. 1am to 4am = 3hr instead of correctly showing 2hr. In the fall, it could show one less hour. e.g. 1am to 4am = 3hr instead of correctly showing 2h.

Where to look for this

Duration bugs often show up in reports and billing code. Reports are often put together quickly to satisfy a new business requirement and the calculations aren’t always verified as stringently. Check anything that relies on an hourly rate, or metered billing.

Here are some common areas to check:

  • PDF reports (time clock, billing, etc)
  • Dashboards (aggregated “time doing X”, dollars billed)
  • Billing calculations (account balance, automatic payment calculations, invoice calculations)

Putting it all together

Durations are everywhere around us. We need them for so many applications. If we aren’t careful about how we use them, we can end up over charging, over paying or getting angry support requests. Do it right, and we get to carry on to bigger and better things.

Autofill forms in seconds with Testing Taxi Extension for Chrome
  • Autofill Tedious Forms with One Click
  • Always on Spell Check
  • Live locator copy/paste
  • Instant warnings and test suggestions

Navigation

Share the Post:

Related Posts

Autofill forms in seconds with Testing Taxi Extension for Chrome
  • Autofill Tedious Forms with One Click
  • Always on Spell Check
  • Live locator copy/paste
  • Instant warnings and test suggestions