At this risk of me feeling stupid, could you briefly explain the benefit of this?

I just added a link to the code with a brief comment. Basically, it simplifies the leap year date calculation. If February is the last month of the year, then the possibly-existing leap day is the last day of the year. If you do it the normal way your calculations for March through December need to know whether February is a leap year. Now none of that is needed. You don’t even need explicit code to calculate whether a given year is a leap year: it’s implicit in the constants 146097, 36524, and 1461.

The magic numbers at the end of this explanation are the number of days of each part of the leap year cycle:

146097 days = 400 year portion of the leap year cycles (including leap years during that)

36524 days = same for the 100 year portion of the leap year cycles

1461 days = 4 year cycle + 1 leap day

IIRC, it's also why the leap day was set to Feb 29th in the first place. At the time (romans?) the year started March 1st.

In case someone was wondering why in the world someone said we should add a day to the second month of the year...

The calendar was regularized to include a leap day during the reign of Julius Caesar (hence the name "Julian calendar"), which would have been 45 BC.

The Roman calendar moved to January as the first month of the year in 153 BC, over a hundred years before the leap day was added. The 10-month calendar may not have even existed--we see no contemporary evidence of its existence, only reports of its existence from centuries hence and the change there is attributed to a mythical character.

Btw, the Romans had leap days before Julius Caesar, but they were added ad hoc by the Pontifex Maximus.

Caesar happened to be the Pontifex Maximus (an office you hold for life once elected to), but he wasn't in Rome much to do that job. So after he came back from hanging out with Cleopatra in Egypt he came back and set the calendar on auto-pilot.

> The Roman calendar moved to January as the first month of the year in 153 BC, over a hundred years before the leap day was added.

Note that some sources suggest that February might still have been the last month, placed after December and before January.

Are you saying that while we do see evidence that September, October, November, December were once the 7th, 8th, 9th, and 10th month, we don't see any evidence that the calendar was ever "10 months long"? (How would that have worked anyway, did they have more days per month?)

Pretty much.

> How would that have worked anyway, did they have more days per month?

The way I've heard, they just simply didn't track the date during the winter.

Wikipedia gives 3 dates for January being the first month, either (approx) 700, 450, 150 BCE.

It's fair to say January was the first month of the Roman calendar; despite it having formerly been March.

I don't know if it ever made it to production, and I don't remember exactly why it made sense at the time, but one early hack I did was passing a date in Julian format because there weren't enough bits to pass a full timestamp.

That's correct, the Romans had March as the first month of the year, so leap day was the last day of the year and September, October, November and December were the 7th (sept), 8th (oct), ninth (nov) and 10th (dec) months.

June and July used to be Quintilis and Sextilis.

I think Quintilis and Sextilis were renamed to July and August, in honor of Julius and Augustus, respectively.

[deleted]

And (oct)ober was the 8th month of the year, (nov)ember the ninth, (dec)ember the tenth!

Weird parenthesization. The latin numbers are septem, octo, novem, decem for 7, 8, 9, 10. And then they all have a -ber suffix.

The three letter prefixes show up in English (eg oct in octal, dec in decimal, etc.).

The prefix in "decimal" is "decim", like you'd expect given that the root is "decem". There is no "dec-" prefix.

(You do see "deca" used as a prefix, "a" included, but that doesn't come from Latin.)

You are right. I should have written: (septem)ber was the 7th month of the year, (octo)ber was the 8th, (novem)ber the ninth, and (decem)ber the tenth!

Don't forget (sep)tember being the 7th month

Technically, the leap day (bissextus) was the 24th. (Wikipedia tells me this is because that's when Mercedonius used to be, before the Julian reforms.)

It's easy to know what day of the year it is because leap days are at the end.

Not so relevant, but some fun history, the Roman calendar did start in March, so tacking on the leap years was done at the finale. This also meant that the root of the words - the "oct" in october means 8 was also the eighth month of the year.

As well as the leap year stuff people have mentioned, there was something else that I've got a vague memory of (from an old SciAm article, IIRC, which was about using March as the first month for calculations) which pointed out that if you use March as 0, you can multiple the month number by (I forget exactly what but it was around 30.4ish?) and, if you round the fraction up, you get the day number of the start of that month and it all works out correctly for the right 31-30-31 etc sequence.