I get headaches just thinking about adjusting for different time zones. Actually, if time zones we’re pizzas I’d never order one. That’s how much trouble they give me. The concept behind time zones is very simple and makes perfect sense, but there are some inconsistencies that drive me nuts.

Confusing

First of all, time zones do not follow geography but are politically decided in the various countries. England has time zone GMT while France has GMT + 1. If you look at a map you’ll see that England is just north of France which would indicate that they used the same time zone, but of course they don’t. You’ll also notice that Spain is actually located west of the Greenwich median which would indicate that they used GMT just like England. Again, that is not the case. I could go on about this, but the fact is that it is really confusing.

Then there is the whole issue about daylight savings time (DST), which some countries have and some don’t. What it means is that the time zone offset between a country using DST and one that doesn’t varies from summer to winter. It just makes me even more confused.

Server time vs. local time

When you are developing websites that must take the users time zones into account then you can get into big trouble. If you only have one installation of the website, then you can control the server’s time zone and let the users pick theirs and everything is good. But if you build a web application that people can upload to their hosting provider of choice, then you cannot control the time zone anymore. You have no idea what time zone the server is running and if you do, you don’t know if it is the correct one and if it’s using DST.

So, what good does it do to let the users pick their time zone if you don’t even know how to convert it to the server’s? No good at all.

WordPress realized this and did something else which is quite brilliant. They knew that letting the users pick their time zone didn’t help to determine their local time against the server’s, so instead they made the user pick the time offset between the server and them selves. If the server time is 4:15pm and your local time is 8:15pm, then you just pick the offset +4.

It’s brilliant and at the same time sad that we in 2007 can’t figure this out in a consistent way without running into trouble. Another possibility is that I’m just slow and haven’ figured out how to do it properly. I’ll let you decide.

I’ve received quite a few e-mails about my last post about unit testing and have followed some reactions around the blogosphere as well. There seem to be common believe that I don’t like unit testing or advice against it. This was not the intent.

I know the post sounds very much against unit testing, but that is just poor semantic skills from my side. To sum up what I really meant; here it is:

Unit testing is very useful in some scenarios, but is overkill in others.

Now you might be thinking: So how do I know when unit testing is overkill? The short answer is experience.

If you have enough experience to fully understand the scope of your project and find that you have done similar things many times before successful, then you know. It’s that simple.

When in doubt, unit test - you can do it in a console.