What Is Date::ITALY?

· coding · Source ↗

TLDR

  • Ruby’s Date::ITALY (2299161) encodes the Julian day number of Italy’s 1582 switch from the Julian to Gregorian calendar.

Key Takeaways

  • Date::ITALY, Date::ENGLAND, Date::GREGORIAN, and Date::JULIAN are all Julian day number constants controlling Ruby’s calendar reform cutoff.
  • Ruby raises Date::Error for dates in the 10-day gap (Oct 5-14, 1582) and silently skips them when iterating under the default Date::ITALY start.
  • Julian Day Numbers count days from a fixed epoch (noon UTC, Jan 1, 4713 BC) to resolve ambiguity across calendar systems that switched at different times.
  • Date::GREGORIAN is -Infinity (always Gregorian), Date::JULIAN is Infinity (never switch), and you can pass any custom Julian day as the start argument.
  • Russia’s 1918 Gregorian adoption (Julian day 2421639) can be modeled with a custom start value: Date.new(1918, 1, 31, 2421639).next_day returns Feb 14.

Hacker News Comment Review

  • No substantive HN discussion yet; the single comment speculates about Paradox grand strategy games (Europa Universalis) handling in-game calendar reform events, which is adjacent but unverified.

Original | Discuss on HN