← Retour au blog
tech 5 August 2026

Dates That Don't Exist: A Dive into the Gregorian Calendar Transition

In 1582, a pivotal transition moved the Catholic world from the Julian to the Gregorian calendar, erasing ten days from history. Let's explore how modern programming languages handle these 'non-existent dates'.

Article inspired by the original source
Dates That Don't Exist (2015) ↗ blog.yossarian.net

Introduction

In 1582, under the papal bull Inter gravissimas, the Catholic world experienced a temporal revolution: the transition from the Julian to the Gregorian calendar. This change was aimed at correcting the growing drift between the solar year and the civil calendar. The result? Ten days were simply erased from history, creating what we now refer to as 'dates that don't exist'. But what happens when we try to handle these dates in programming?

The Calendar Transition

The Julian calendar, established by Julius Caesar, accounted for 365.25 days per year, with an extra day every four years. However, this approximation created a drift of about one day every 128 years. To correct this, the Gregorian calendar reduced the year to 365.2425 days. This change required the removal of ten days in October 1582, jumping directly from the 4th to the 15th.

Handling Dates in Programming

Ruby: The Good Student

Ruby stands out for its strict handling of impossible dates. For instance, trying to create a date for October 5, 1582, results in an error:

``ruby require 'date' DateTime.new(1582, 10, 5) # => ArgumentError: invalid date ``

This shows that Ruby adheres strictly to Gregorian calendar rules.

Python: A Different Approach

In contrast to Ruby, Python allows for the creation of these invalid dates through its datetime module:

``python from datetime import date date(1582, 10, 5) # => datetime.date(1582, 10, 5) ``

This flexibility might lead to errors in historical calculations.

Perl: A Solution via CPAN

Perl lacks a standard equivalent to Ruby's DateTime or Python's date, but uses the DateTime module from CPAN, which can also err on these dates.

Implications for Development

Understanding how programming languages handle dates is crucial, especially for applications related to history, finance, or science. Mismanagement can lead to costly errors.

Conclusion

Handling 'dates that don't exist' reveals significant differences among programming languages. Whether you're a developer or a decision-maker, understanding these nuances is essential to ensure the integrity of your applications. Let's discuss your project in 15 minutes.

calendrier grégorien dates impossibles programmation Ruby Python
Deepthix newsletter · 100% AI · every Monday 8am

An AI agent reads tech for you.

Our AI agent scans ~200 sources per week and ships the best articles to your inbox Monday 8am. Free. One click to unsubscribe.

Visit the newsletter page →

Want to automate your operations?

Let's talk about your project in 15 minutes.

Book a call