惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
博客园 - 【当耐特】
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Check Point Blog
月光博客
月光博客
腾讯CDC
Engineering at Meta
Engineering at Meta
博客园 - Franky
Vercel News
Vercel News
D
Docker
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Fortinet All Blogs
Microsoft Security Blog
Microsoft Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
雷峰网
雷峰网
Google DeepMind News
Google DeepMind News
Martin Fowler
Martin Fowler
GbyAI
GbyAI
B
Blog
Hugging Face - Blog
Hugging Face - Blog
T
Tailwind CSS Blog

Hacker News

GitHub - SeanFDZ/macmind: Single-layer transformer in HyperTalk for the classic Macintosh Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis Bonsai 1-bit WebGPU - a Hugging Face Space by webml-community Moving a large-scale metrics pipeline from StatsD to OpenTelemetry / Prometheus GitHub - Nightmare-Eclipse/RedSun: The Red Sun vulnerability repository GitHub - SethPyle376/hiraeth: Local AWS emulator focused on fast integration testing, with SQS support, SQLite-backed state, and a debug-friendly web UI. GitHub - macOS26/Agent: Any AI, replaces Claude Code, Cursor, OpenClaw. Over 18 LLM providers (Claude, OpenAI, Gemini, Ollama, Zai, HF, Qwen) wired into a native Mac app that writes code, builds Xcode projects, bumps versions, manages git, automates Safari, use AppleScript, JS or Accessibility, extend Agent! w/ MCP Servers, run tasks from your iPhone via Messages. YouTube now lets you turn off Shorts I Made a Terminal Pager Burgers | マクドナルド公式 Commands — HackerNews CLI documentation ChatGPT for Excel PiCore - Raspberry Pi Port of Tiny Core Linux Live Nation illegally monopolized ticketing market, jury finds Google Broke Its Promise to Me. Now ICE Has My Data. Founding Engineer at Adaptional | Y Combinator CRISPR takes important step toward silencing Down syndrome’s extra chromosome GitHub - saffron-health/libretto: The AI toolkit for building reliable browser automations US v. Heppner (S.D.N.Y. 2026) no attorney-client privilege for AI chats [pdf] Retrofitting JIT Compilers into C Interpreters IPv6 – Google The Accursèd Alphabetical Clock Cybersecurity Looks Like Proof of Work Now Fragments: April 14 Cal.com Goes Closed Source: Why AI Security Is Forcing Our Decision | Cal.com - Scheduling Software for Online Bookings Laravel raised money and now injects ads directly into your agent When moving fast, talking is the first thing to break Too much Discussion of the XOR swap trick – Heather Cafe Introduction to Spherical Harmonics for Graphics Programmers The Grand Line
What is Date::ITALY?
2026-05-17 · via Hacker News

The other day I was perusing a Ruby backtrace and paused as something caught my eye: Date::ITALY. What could that be?

irb(main):001> Date::ITALY
=> 2299161

Allrighty, not exactly self-explanatory. Upon visiting the documentation for class Date, I was greeted by a few other unusual sounding constants, including ENGLAND, GREGORIAN, and JULIAN. What do the docs have to say about these?

ENGLAND
The Julian day number of the day of calendar reform for England and her colonies.

GREGORIAN
The Julian day number of the day of calendar reform for the proleptic Gregorian calendar.

ITALY
The Julian day number of the day of calendar reform for Italy and some catholic countries.

JULIAN
The Julian day number of the day of calendar reform for the proleptic Julian calendar.

First of all, I think it is humorous that the Ruby source code mentions England and her colonies as well as some catholic countries. Second, I learned the term proleptic, which refers to extrapolating calendar dates outside the time of their adoption or use. But OK, the question on everyone’s mind – what is a Julian day number? Well, not so fast, because first we have to cover the catholicism part.

The Gregorian Switchover

The Julian calendar, established by the eponymous Caesar, had been cooking along fairly accurately for quite some time. But, it wasn’t perfect, losing a day about every 128 years. By the time of Pope Gregory XIII in the 1580s, the date of Easter had unacceptably moved about two weeks towards the Summer. In 1582, the Papal bull Inter gravissimas declared that the day following Thursday, 4 October 1582 would be Friday, 15 October 1582. Indeed, Ruby conforms, raising an exception if you attempt to instantiate a date within that ten day period:

irb(main):001> Date.new(1582, 10, 5)
(irb):1:in 'Date#initialize': invalid date (Date::Error)

and helpfully hops right over them when iterating, like it never happened:

irb(main):001> Date.new(1582, 10, 4).next_day
=> #<Date: 1582-10-15 ((2299161j,0s,0n), +0s,2299161j)>

Wait a moment, where have we seen that number before? Yes, Date::ITALY encodes the Julian day on which Italy switched from the Julian calendar to the Gregorian calendar – Julian day 2,299,161. If you were ever wondering what those weird numbers were in Date#inspect, those are Julian Day numbers.

Julian Days

Like all good stories, this one starts over six thousand years ago. On a very special Monday, New Year’s day in 4713 BC, at exactly noon UTC, the three most important multi-year cycles of humankind were perfectly synchronized: the 28 year solar cycle, the 19 year lunar cycle, and of course the 15 year Roman tax collection cycle, commonly referred to as the indiction cycle. Indeed, the Julian day cycle is a period of 28 x 19 x 15 = 7980 years, which will roll over once again in the year 3268 AD.

Why do we need this? As we saw earlier, there are some ‘gaps’ in the accounting of days in human history. To add to the confusion, not all countries adopted the Gregorian calendar at the same time – England for example, waited until 1752, as the Protestants were hesitant to adopt Catholic innovation (hence, Date::ENGLAND). Therefore, a sort of ‘universal intermediary’ was required to compute back and forth unambiguously between various calendar systems. Thus a simple count of days from a somewhat arbitrary epoch was created. Literally 1 year after the introduction of the Gregorian calendar, scholar Joseph Scaliger proposed the Julian Period method. Unbelievably confusingly, this Period was not named for the Julian calendar, or Julius Caesar that it was named after – it was named after his father Julius Caesar Scaliger, who was himself named after Julius Caesar. This is not unlike the Caesar salad, famously named after Caesar Cardini (famously named after Julius Caesar (whose name is famously actually Gaius.))

Ok, back to Ruby. We now know that Date::ITALY and Date::ENGLAND define the Julian day number that Italy and England respectively adopted the Gregorian calendar. That leaves Date::GREGORIAN and Date::JULIAN. I bet you’ll never guess:

irb(main):001> Date::GREGORIAN
=> -Infinity
irb(main):002> Date::JULIAN
=> Infinity

Alrighty, not exactly self-explanatory. To make sense of this, we will have to understand the Date initializer:

new(year = -4712, month = 1, mday = 1, start = Date::ITALY)

Two things here: first, the default date is equivalent to Date.jd(0). If you have ever wondered why Date.new.to_s gives "-4712-01-01", now you know. Second, the optional start argument is the ‘start of the Gregorian calendar’, expressed in Julian Days.

If you were working on a SaaS product in England in the 1700s, you would express Sir Isaac Newton’s DOB as Date.new(1642, 12, 25, Date::ENGLAND) rather than Date.new(1643, 1, 4). This also means that Date.new(1582, 10, 5, Date::ENGLAND) does not raise an exception like it does for Date::ITALY. In English parlance, Isaac’s birthday expressed as 1642/12/25 would be called the ‘old style’, and 1643/1/4 the ‘new style’ date. This is why Ruby’s date_core.c often mentions os and ns.

If you always want to use the Julian calendar, you could kick the ‘Gregorian switchover’ can infinitely down the road. This is why Date::JULIAN is Float::INFINITY. Passing Date::GREGORIAN (-Float::INFINITY) implies that the switchover happened ‘infinitely long ago’, or in other words, ‘we have always been using the Gregorian calendar’.

Because these values are assumed to be Julian Days, you can also provide your own arbitrary values. For example, if you wanted to model dates in Russia, where the Gregorian calendar was adopted on 14 February, 1918, you would:

irb(main):001> Date.new(1918, 1, 31, 2421639).next_day
=> #<Date: 1918-02-14 ((2421639j,0s,0n),+0s,2421639j)>

God help us if we ever switch to a new calendar system, because a single start argument won’t cut it anymore!

Closing Thoughts

If you are wondering if Isaac Newton actually was born on Christmas or rather January 4th, well, that is exactly the issue that Gregory XIII was out to solve!

Because the Julian Period is a synchronization of three other cycles, it is referred to as a tricyclic system.

The indiction cycle may have been chosen as a third cycle because historical records often were linked not to a date but rather an indiction number.

Contrary to what I said above, it is contested as to whether the Julian Period was originally referring to the Julian calendar or rather named after Joseph’s father.

Conceptually, you can think of a Date as a (julian date, gregorian switchover) tuple, combined with methods that compute answers based on those two values. In the inspect format of a date, for example #<Date: 1582-10-15 ((2299161j,0s,0n), +0s,2299161j)>, you are seeing the date expressed as a Julian day number, plus the seconds and nanoseconds of a time component, then a time zone offset, and finally the provided Julian day of the Gregorian switchover. A DateTime will use the 0s, 0ns portion for the time component.

Left as an exercise for the reader, there are a few fun methods in class Date as well:

  • #gregorian_leap?
  • #julian_leap?
  • #jisx0301
  • #rfc2822
  • #rfc3339

Further Reading

  • https://docs.ruby-lang.org/en/master/language/calendars_rdoc.html#argument-start
  • https://github.com/ruby/ruby/blob/master/ext/date/date_core.c
  • https://quasar.as.utexas.edu/BillInfo/JulianDatesG.html
  • https://en.wikipedia.org/wiki/Julian_day