The Ten Days That Never Happened: How Programming Languages Handle a Missing Slice of 1582

Dates That Don't Exist (2015)

The Ten Days That Never Happened: How Programming Languages Handle a Missing Slice of 1582

In 1582, the Catholic world skipped ten days to switch from the Julian to the Gregorian calendar, making October 5–14 of that year nonexistent. This post tests how Ruby, Python, and Perl's DateTime handle these impossible dates. Ruby correctly raises an error, while Python and Perl silently accept them, revealing a gap in date/time correctness. The author also notes that the ncal tool can be more accurate by accounting for different countries' adoption dates.

In essence, then, those ten days in 1582 never happened and simply do not exist within the Gregorian calendar system used almost universally in the West today.
  1. autarch

    I'm the author of the Perl DateTime library. It works correctly as _documented_. Here's the first two paragraphs of the docs:

    > DateTime is a class for the representation of date/time combinations, and is part of the Perl DateTime project.

    > It represents the Gregorian calendar, extended backwards in time before its creation (in 1582). This is sometimes known as the "proleptic Gregorian calendar". In this calendar, the first day of the calendar (the epoch), is the first day of year 1, which corresponds to the date which was (incorrectly) believed to be the birth of Jesus Christ

    Always RTFM.

    Edit: I double-checked, and while this was not in the docs in the first release, it _was_ in the docs as of 2015.

    https://metacpan.org/pod/DateTime

  2. maxlybbert

    This is an interesting detail to learn about history. However, like the article mentions near the end, the Gregorian calendar was adopted at different times in different countries. The Anglican Church didn’t trust the Catholics, so Great Britain adopted the Gregorian calendar in 1752 ( https://en.wikipedia.org/wiki/Calendar_(New_Style)_Act_1750 ). And they did their best to hide the fact that they were adopting a Catholic invention: it’s the “New Style Calendar” and they came up with a different way to choose the same date for Easter.

    1752 is late enough that Benjamin Franklin, George Washington, Thomas Jefferson and others were born before that change.

    I think that’s the reason that programming languages tend to adopt the proleptic Gregorian calendar and leave it up to the programmer to figure out when the calendar was adopted in the countries they care about.

    Except that countries apparently had to answer various questions when they adopted the Gregorian calendar, and they didn’t all chose the same answers. Ideally, we’d have something like tzdb but for calendar adoption. But I guess the need doesn’t come up all that often.

  3. woodruffw

    It’s funny to see this on HN. I wrote this 11 years ago as an undergraduate.

    The afternotes at the end of the post are worth reading; people have sent me various qualifications and corrections over the years.

  4. throwawayk7h

    So, the Proleptic Gregorian Calendar[1] refers to what you'd get if you extended the current Gregorian Calendar back in time before its introduction. (It agrees with the Julian calendar only during the 3rd century AD.) Most date libraries use the Proleptic calendar for simplicity. Ruby's DateTime is unusual insofar as, by default, it actually switches to the Julian calendar for dates before Oct 15 1582.

    [1] https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar

  5. SoftTalker

    There seems to be disagreement about the year. Two systems I checked assume 1752, not 1582.

    (OpenBSD)

    $ man cal

    [...]

    The Gregorian Reformation is assumed to have occurred in

    1752 after the 2nd of September. By this time, most

    countries had recognized the Reformation (although a few

    did not recognize it until the early 1900s). Eleven days

    following that date were eliminated by the Reformation, so

    the calendar for that month is a bit unusual.

    (Ubuntu Linux)

    [...]

    -s country_code

    Assume the switch from Julian to Gregorian Calendar at

    the date associated with the country_code. If not

    specified, ncal tries to guess the switch date from the

    local environment or falls back to September 2, 1752.

    This was when Great Britain and her colonies switched

    to the Gregorian Calendar.

More from this day

2026-08-04