Dates That Don't Exist (2015)
This post dives into the historical oddity of the 10 "missing" days in October 1582, a consequence of the Gregorian calendar reform. It then meticulously examines how popular programming languages like Ruby, Python, and Perl handle these historically non-existent dates, revealing a surprising lack of universal correctness. Such niche, precise technical problem-solving, coupled with intriguing historical context, resonates strongly with the Hacker News community.
The Lowdown
The author delves into a peculiar historical event: the 10 days that "never happened" in October 1582, due to the transition from the Julian to the Gregorian calendar. This intriguing historical detail sets the stage for a technical examination of how programming languages cope with such calendrical anomalies, highlighting the challenges of achieving true correctness in date and time implementations.
- The Gregorian calendar reform in 1582, initiated by the inter gravissimas papal bull, necessitated the removal of 10 days (October 5-14) to correct accumulated drift relative to the Julian calendar.
- These 10 days effectively "do not exist" in the modern Gregorian calendar system for regions that adopted it immediately.
- The article tests how several programming languages handle these dates:
- Ruby: Correctly raises an
ArgumentErrorwhen attempting to create aDateTimeobject for these non-existent dates. - Python: Incorrectly allows the creation of
dateobjects for these days, despite claiming to represent the "current Gregorian calendar." - Perl: Using the
DateTimemodule, also incorrectly permits the creation of these dates without an error.
- Ruby: Correctly raises an
- The author notes that while not a major issue, this disparity illustrates the varying levels of correctness in date and time implementations across languages.
- Afternotes: The post also details how non-Catholic regions adopted the Gregorian calendar much later (e.g., Great Britain in 1752), each requiring their own specific date removals.
ncal(1): Thencalutility is highlighted for its sophisticated approach, allowing users to specify a country code to determine when that specific region transitioned, making it highly accurate for historical contexts.- Addendum: A later addendum points out
ncalis still not perfectly correct, specifically missing Sweden's complex calendar shifts in the 1700s.
This mini-post offers a fascinating blend of history and computer science, demonstrating that even seemingly simple tasks like date handling can hide layers of historical complexity that challenge the precision of modern software. It underscores the ongoing pursuit of "correctness" in programming, especially when interfacing with real-world, sometimes messy, historical data.