Having worked on a couple of software systems that required localisation for multiple countries, I've encountered many situations where, much to my dismay, I've needed to dip into the baffling world of international time zones. Time zones are one of those awkward real-world domains, the rules for which have evolved independently over many years across many different authorities. They are chock-full of arbitrary edge cases that fly in the face of the kind of neat, organised abstractions that software developers love. Tom Scott sums up the problems brilliantly in one of his videos from the Computerphile channel on YouTube, The Problem With Time & Timezones.

Like many domains of this nature, you find that just at the point that you think you've understood, another curve-ball is thrown that makes you question everything. I had an experience like this a couple of years ago, when I found that my local time at the Unix epoch appeared to be wrong.

Back in the 1970s, a format for storing dates and times was invented for the Unix operating system. This format was simply a count of the number of seconds since a fixed point in time: Midnight UTC on 1 January, 1970. This point in time is referred to as the Unix epoch. Due to its simplicity and relative lack of ambiguity, Unix time has become commonplace in all kinds of software. UTC, by the way, is the same as Greenwich Mean Time (GMT) for all intents and purposes.

My local time zone, in the UK, is GMT. However, for half the year between March and October, Daylight Savings Time is observed and the local time becomes one hour ahead of GMT. This is known as British Summer Time (BST). This shifting definition of local time can cause all manner of weird problems, with its missing and repeated hours and lack of one-to-one mapping with GMT. While working on a system where times were stored as GMT, but date arithmetic was done in UK time, I found daylight savings to be the cause of a lot of bugs.

Eventually, though, I thought I'd grasped all the nuances of Unix time, GMT and UK time. The Unix epoch was in January, which is between October and March so the UK would have been in sync with GMT. It was at midnight, so the time in the UK should have been midnight too, right? Imagine my horror, then, when the date command on my Linux machine gave me this as the UK time at the Unix epoch:

$ date -d @0
Thu  1 Jan 01:00:00 BST 1970

1 am BST? Daylight savings time in January? Had I misunderstood what BST was? Was the time zone database on my machine corrupt? Was it a bug? Was there some other definition of Unix time that I didn't know about?

It turns out it was none of these things. In 1970, the UK government happened to be experimenting with using daylight savings time all the year round in an attempt to reduce road accidents. This experiment, the "British Standard Time" experiment, only lasted between 27 October 1968 and 31 October 1971. A short-lived change, which has never happened since, and which happened to coincide with one of the most important dates in modern computing. Thanks a bunch, guys!