What Is Date::ITALY?

· coding · Source ↗

TLDR

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

Key Takeaways

  • Date::ITALY, Date::ENGLAND, Date::GREGORIAN, and Date::JULIAN are Ruby constants encoding Julian day numbers for calendar reform transitions.
  • Ruby raises Date::Error for dates in the 10-day gap (Oct 5-14, 1582) and silently skips them when iterating.
  • Date::JULIAN is Float::INFINITY (never switch to Gregorian); Date::GREGORIAN is -Float::INFINITY (always Gregorian).
  • The optional start argument in Date.new lets you model any country’s switchover, including Russia’s 1918 adoption via Julian day 2421639.
  • Julian day numbers count continuously from noon UTC on Jan 1, 4713 BC, a tricyclic synchronization of 28-year solar, 19-year lunar, and 15-year indiction cycles.

Hacker News Comment Review

  • Commenters noted calendar adoption was not uniform even within countries: cities and religious communities (Protestant vs. Catholic) could operate on different calendars simultaneously, creating ambiguity about which date to use depending on the recipient of correspondence.
  • Julian dates are still used in encrypted radio systems and astronomy precisely because they skip no days, functioning like a pre-Unix epoch continuous counter without timezone handling.
  • The fuzzed-input test bug where one random seed exposed date-handling errors illustrates that Ruby’s calendar-gap behavior can surface as surprising runtime failures far from obvious call sites.

Notable Comments

  • @cdot2: Julian dates are used in encrypted radio timing systems; astronomers adopted them because the continuous count avoids gaps that would break long-term cycle tracking.

Original | Discuss on HN