Time zone support has been the bane of many developers who've worked with events and other time and date related information in Drupal. To make matters worse, the way time is handled in Core is different from (and not completely compatible with) the approach taken by the Event module.
Since there are a number of competing solutions that have been proposed, it makes sense to start with a survey of use cases where people care about time zones, a list of common problems, and a short critique of some of the things that have been tried up until now. I encourage anyone with a strong opinion about a particular solution (con or pro) to attach a child page to make your case.
Definitions Of Terms
While most or all of us have lived in places that observe "Day Light Savings Time" (DST) or "Summer Time", as it is called in parts of Europe, it's useful to define some terms that are commonly used in time and date libraries a bit more precisely to prevent common misunderstandings. Here are a few:
- UTC: Coordinated Universal Time. I'm assuming that the order comes from the French. In any case, this is the CCITT's term for what people often call "GMT", i.e., the time in the UK with no change for summer time. Since the UK actually does observe summer time, the local time in Greenwich can be an hour off from GMT. Go figure.
- Offset: The difference in seconds between local time and UTC. The offset is greater than 0 for zones to the east of Greenwich, and less than 0 for zones to the west of it. Offsets do not have be full hours. Parts of Australia and Canada, for example, are in zones that are a some number of hours and a half off from UTC. A few zones are 15 minutes off of a full hour.
- Unix Time Stamp: the number of seconds since the Epoch, which is defined as 12AM on January 1st, 1970 UTC. Time stamps are always for UTC, by definition, and the standard time libraries always treat them this way. More on this point later.
- Transition Rules: a "rule" that defines when to move from standard time to summer time ("2 AM local time on the last Sunday of the month of March"). Every country has to have their own damn rules.
- Transition Time: the time, expressed as a Unix Time Stamp, when a time zone changes between standard time and summer time. The most commonly used time library, based upon code maintained by Arthur Olson of the US National Institute of Health, works by compiling Transition Rules into binary files containing arrays of transition times.
- Time Zone: a time zone is a geographic area with a base offset from UTC, which may or may not have transition rules defined for DST. If a zone uses the same offsets but different transition rules, time zone libraries treat it as a distinct zone.
- POSIX Time Zone Name: This is a string that can be used for the TZ environment variable on most Unix systems. Usually, it's of a form like "America/Los_Angeles". The Olson database has more than 500 different zone names.
These are a lot of definitions, but to discuss this, it helps in comparing different solutions to know how well they handle local time for different countries and localities.
We'll look at different aspects of the problem, including use cases, common problems and bugs, and some different solutions.