The Problem with Time & Timezones - Computerphile - Summary

Summary

The speaker shares a cautionary tale about dealing with time zones in programming. They describe a hypothetical programmer who creates a simple application to calculate the number of seconds between two dates but soon encounters the complexity of time zones, daylight saving time, and leap seconds. The programmer struggles to keep up with the various time zone rules, updates, and exceptions, including countries that change their time zones with little notice, populations that follow different time zones in the same location, and historical date changes.

The speaker eventually concludes that trying to write code to handle all these complexities is "madness" and recommends using existing open-source solutions that have already dealt with these issues. They also mention Google's approach to leap seconds, called a "leap smear," which involves smearing the extra second over the entire day to maintain continuity and accuracy.

Facts

Here are the key facts from the text:

1. Every programmer has to deal with time zones at some point.
2. Time zones can be complex and vary by country, region, and even city.
3. Some countries, like Australia, are ahead of Greenwich Mean Time (GMT) by a non-whole number of hours.
4. Nepal is five and a quarter hours ahead of GMT.
5. Some countries observe daylight saving time, which can add complexity to time zone calculations.
6. The start and end dates of daylight saving time can vary by country and region.
7. Some countries, like Samoa, have skipped days in the past to change their time zone.
8. Libya changed its time zone in 2013 with only a couple of days' notice.
9. The West Bank has two populations with different time zones.
10. Historically, the start of the year was not always January 1st, but varied by country and century.
11. The Julian calendar was used before the Gregorian calendar.
12. The International Astronomical Union determines when a leap second is needed to keep clocks in sync with the Earth's rotation.
13. Leap seconds can cause problems for computer systems and software.
14. The Unix timestamp is a way to represent time that is not affected by leap seconds.
15. Google has developed a "leap smear" approach to dealing with leap seconds, which involves smearing the extra second over the course of a day.