案例库 · 软件与 IT · 技术决策 · 1988-2002
这条还没译成中文,下面是英文原文。
ISO 8601 won computing's dates by writing the biggest unit first.
ISO 8601 orders date components largest-to-smallest (YYYY-MM-DD), so date strings sort chronologically; RFC 3339 carried it onto the internet.
ISO · IETF
那一手
People write dates as month/day/year, day/month/year or year/month/day, and each is ambiguous outside its home. In 1988 ISO standardized the parts into a single format, 8601.
The design is deliberately big-endian: year, then month, then day, from the largest to the smallest unit, with fixed-width zero-padded fields. RFC 3339, published in July 2002, provided an internet profile and specified a date-only form of YYYY-MM-DD.
That ordering is the trick. Components ordered from least to most precise mean a string also sorts by time, so code, file names and databases can order dates without parsing them, and data can move between systems without ambiguity.
为什么管用
- Largest-to-smallest order makes text sorting match date sorting
- Fixed-width, zero-padded fields allow lexicographic ordering
- It is unambiguous across languages and regions
- A single format removes the need to know the source's convention
可以搬走什么
Choose a representation that turns the hard problem into an artifact of ordering; if strings sort correctly, every system that lists them becomes correct for free.
后来呢
ISO 8601 and RFC 3339 became the de facto dates in APIs, JSON, databases, log files and file names, even where everyday human dates stayed local. It is the rare standard that won by being boring and correct.
资料来源
发现哪里写错了?告诉我们。