Friday, 20 July 2007

Daylight Saving 1: A primer on appointment times

In my previous post I promised an explanation of how changes to Daylight Saving Time affect Outlook. But before we can even look at Daylight Saving, we need to understand how Outlook stores appointment times and copes with time zones.

Outlook stores each appointment with a start time and duration. (The end time isn't stored; Outlook works it out on-the-fly.) The start time is stored as UTC, calculated relative to the time zone of the machine the appointment is created on.

UTC stands for Universal Time Coordination – actually the same as GMT, but we refer to it as UTC to avoid confusion with "London Time" which is an hour off from 'real' GMT for half the year.

The easiest way to get to grips with this is through an example. Imagine Alice is in New York. She creates an appointment to remind her about her dentist appointment at 10am on a Wednesday in December. Outlook does this simple calculation based on the time zone of the computer Alice creates the appointment from:

Local time

10:00

Remove GMT-5 time zone

+5:00

UTC

15:00

So Alice's 10am appointment is actually stored at 15:00 UTC.

Two things to note: first, I deliberately chose December because daylight saving won't apply, and second, I'm using 24-hour clock times for simplicity.

When an appointment is viewed, Outlook converts the start time from UTC back to Local Time based on the time zone settings of the local computer.

So Alice views the appointment at her computer in New York, she'll see it as happening at 10am and never needs to know this calculation back and forth took place. But what if Alice were to view her calendar from another time zone?

Let's say Alice travels to Mumbai, and uses a local machine in the Mumbai office to view her Calendar, which she can do because it's stored on the Exchange server. India's Time Zone is GMT+5.5 so her dentist appointment will appear at the following time:

UTC (which we worked out already)

15:00

Adjust to GMT+5.5 time zone

+5.30

Local time in Mumbai

20:30

Nothing has changed in the way the meeting is stored, just the machine it's being viewed from has a different time zone so it appears with a different start time.

So now we'll add DST into the mix. Here's how the calculations would work if the appointment had been in June:

Local time in New York

10:00

Remove GMT-5 time zone

+5:00

Remove daylight saving hour

-1:00

UTC

14:00

so the appointment would be stored at 14:00 UTC

and the display time would be:

UTC (from above)

14:00

Adjust to GMT+5.5 time zone

+5.30

No adjustment for DST

0:00

Local time in Mumbai

19:30

(Some places don't do daylight saving at all. India is one of them.)

Next time I'll cover some of the things we see working across time zones which do DST differently.

No comments:

Post a comment

Creative Commons License This work by TechieBird is licensed under a Creative Commons Attribution-No Derivative Works 2.0 UK: England & Wales License.