20 January 2006

You know how many time zones they got?

Here are a couple of questions that every fledgling programmer should be asked:
  1. How many time zones are there in the world?
  2. How many hours are in a day?
The naïve answer—the answer I would have given—to both is "24". And that answer is wrong for both.

It turns out that the world has many more than 24 time zones. For instance, so that nowhere in India is local sun time too far off from the official time, the country is 5:30 later than GMT. And Nepal, just to show that it's different from India, is another 15 minutes later.

The answer to the second question is "it depends". I discovered this when I was analyzing some logs from machines in several locations around the world. One thing I was calculating was their productivity per hour, and I calculated it by taking the amount of work each had done during a calendar day and dividing by 24. One day I noticed that all of the machines in the US showed about a 4% drop in productivity; the ones in other countries didn't. The next day they were all back to normal. This puzzled me until I analyzed the logs over the previous year, and found a day when US machines had a 4% increase in productivity. That day was exactly 6 months earlier. The culprit was daylight savings time, which creates a day in October that's 25 hours long, and one in April that's 23 hours long.

So time is harder than you might think, and takes some work to get right.

(And if you don't know the answer to the question in the title to this post, you need to listen to more Negativland.)

Technorati Tags: