时间区数据库令人惊讶的异想天开。
The surprising whimsy of the Time Zone Database

原始链接: https://muddy.jprs.me/links/2026-03-06-the-surprising-whimsy-of-the-time-zone-database/

在代码中处理时区向来非常复杂——最好的方法是利用现有的、虽然错综复杂的IANA时区数据库,而不是尝试从头开始构建解决方案。该数据库现在在GitHub上公开跟踪,细致地记录了世界历史和正在进行的时区变化。 除了简单地列出时间,该数据库还揭示了这个复杂主题中令人惊讶的人性化一面。它包含历史轶事,例如一位加拿大知识分子在1947年对夏令时的诙谐批评,反映政治分歧的“对峙”时钟面故事,甚至还有调查工作以确定偏远地区的时区历史。 虽然时区本身是编程难题的来源,但管理时区的数据库却是人类尝试组织和理解我们与时间关系的一次迷人记录。

## 时区的奇妙世界 最近的 Hacker News 讨论强调了时区数据库 (TZDB) 中令人惊讶的复杂性和“异想天开”。虽然看似简单直接,但 TZDB 必须应对历史变化、政治影响,甚至人们*感知*时间的方式的细微差别,而不仅仅是官方规定。 用户们争论了数据库的结构,一些人提倡由各国管理的基于 DNS 的系统。然而,人们担心依赖可能不可靠的政府更新,以及需要保存历史时区数据——这对于准确解读过去日期至关重要。 这场讨论揭示了 TZDB 设计中固有的妥协,例如摩洛哥斋月等复杂规则,以及为规避相关数据存储库的限制而采取的临时“补丁”。最终,TZDB 旨在在历史和文化中的各种时间系统之间进行转换,这项任务远比简单地记录“官方”时间复杂得多。
相关文章

原文

Time zones are hard. As a well-known Computerphile video so eloquently puts it:

What you learn after dealing with time zones, is that what you do is you put away your code, you don’t try and write anything to deal with this. You look at the people who have been there before you. You look at the first people, the people who have dealt with this before, the people who have built the spaghetti code, and you thank them very much for making it open source, and you give them credit, and you take what they have made and you put it in your program, and you never ever look at it again. Because that way lies madness.

The Canadian province of British Columbia recently decided to switch to permanent daylight time. I wanted to see if this update made it to the IANA Time Zone Database yet. Luckily, we can now view updates to this database as commits on GitHub. And there it was in the news file!

GitHub diff showing an announcement of changes to future timestamps for British Columbia, which is transitioning to permanent daylight time

I’ve perused the tz repository before, and I always learn something interesting. For example, during WWII Britain adopted double summer time, adding two hours to the clock in the summer and one hour in the winter. The bulk of the comments in the database are dedicated to documenting this extensive history of time zone changes across the world.

But for such an important resource (relied upon directly or indirectly by a huge amount of software), the Time Zone Database also contains a surprising amount of whimsy.

Just in the North America file alone, you will find entries like:

  • A spirited attack on daylight savings from Canadian intellectual Roberton Davies in 1947:

I don’t really care how time is reckoned so long as there is some agreement about it, but I object to being told that I am saving daylight when my reason tells me that I am doing nothing of the kind. I even object to the implication that I am wasting something valuable if I stay in bed after the sun has risen. As an admirer of moonlight I resent the bossy insistence of those who want to reduce my time for enjoying it. At the back of the Daylight Saving scheme I detect the bony, blue-fingered hand of Puritanism, eager to push people into bed earlier, and get them up earlier, to make them healthy, wealthy and wise in spite of themselves. – Robertson Davies, The diary of Samuel Marchbanks

  • A story of a public clock in Nashville in the 1950s with “dueling faces”—one time for conservatives and another for liberals.
  • An account of the “day of two noons” in New York City in 1883, when standardized time zones were adopted and “local time” was abandoned forever.
  • A detective story about ascertaining the proper chronology of time zones in Resolute Bay, a tiny community north of the Arctic circle.

Time zones may be madness, but the database that records them is charmingly human.

联系我们 contact @ memedata.com