Last active
October 15, 2024 01:08
-
-
Save coffeemug/6168031 to your computer and use it in GitHub Desktop.
The fun of implementing date support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
After spending the better part of the month implementing date support | |
in RethinkDB, Mike Lucy sent the team the following e-mail. It would | |
have been funny, if it didn't cause thousands of programmers so much | |
pain. Read it, laugh, and weep! | |
----- | |
So, it turns out that we're only going to support dates between the | |
year 1400 and the year 10000 (inclusive), because that's what boost | |
supports. | |
Now, I know all you date-time fans out there have the same question -- | |
"1400? How does that make any sense? Wasn't the Gregorian calendar | |
established some time in the 1500s?" | |
Great question! It turns out that it's the wrong one, though. See, | |
they didn't really have standards bodies or anything back in the day | |
-- there was nobody to "establish" a calendar. The Catholic church | |
came up with the Gregorian calendar in 1582 because the Julian date of | |
Easter as decreed by the first council of Nicaea had drifted from the | |
actual date of the Spring equinox. (The Julian calendar loses about | |
18 hours every century.) | |
So Catholic countries switched to the Gregorian calendar in 1582, by | |
just picking a day and skipping about 10 days forward. (Of course, | |
they all picked different days to skip forward, so there's a period of | |
time toward the end of 1582 where if you pick a random day there's a | |
pretty good chance that that day doesn't exist in at least one major | |
European country.) | |
The Protestant countries took just a tad longer -- about 120 years. | |
Most of them switched over around 1700, with varying degrees of | |
Hijinks. | |
Sweden deserves a special mention here, because they apparently | |
decided that rather than skipping so many days, it would be easier to | |
just not have leap years for a while until they caught up with the | |
Gregorian calendar. That sounds reasonable, until you think about it | |
and realize that they planned to spend 40 YEARS where their own notion | |
of the current date didn't line up with either calendar. | |
And then, best of all, they didn't even do it. They skipped the first | |
leap year, then got into some war or another and just didn't bother | |
skipping the next two. | |
They finally realized that the whole idea was sort of silly (after 12 | |
years, 8 of which were spent not doing it). However, instead of just | |
jumping forward like everyone else, they moved BACK to the Julian | |
calendar by introducing February 30th for the year 1712. (This is the | |
only year where February 30th is a legal Julian date, and only in | |
Sweden.) | |
50 years later, they finally jumped forward to Gregorian like | |
everybody else (at approximately the same time as Britain). | |
Lest you think that this is all a relic of history, Alaska didn't move | |
onto the Gregorian calendar until we bought it from Russia in the late | |
1800s, and Russia itself didn't move onto the Gregorian calendar until | |
1918. | |
China actually moved onto the Gregorian calendar TWICE -- once in | |
1912, and once in 1928. (In between there was a brief period of chaos | |
where several warlords rejected the Gregorian calendar in favor of | |
whatever one they liked best.) | |
Now, though, everyone is basically settled on the Gregorian calendar, | |
except for a few countries (like Iran) that reject it, or (like | |
Israel) use it alongside another calendar, or (like Taiwan) use it but | |
with minor edits. | |
But let's ignore those. Let's say we're in a country X that's on the | |
Gregorian calendar, and we have a date that we know was recorded | |
*after* the last time X moved to the Gregorian calendar (we need "the | |
last time" for cases like China). Then we should be safe, right? | |
Not quite. You see, while we take it for granted now, the year didn't | |
always start on January 1st. Many European countries started the year | |
on some major holy day (like Christmas). Some, like England, even had | |
multiple starts of the year; one that was in common use, and one that | |
was the legal standard. | |
Now most countries switched to starting their years on January 1st | |
before adopting the Gregorian calendar, but some didn't. Holland, for | |
example (then the Republic of the Seven United Netherlands -- don't | |
even get me STARTED on all the cases where groups with different | |
calendars conquered each other, or merged with each other, or began or | |
ceased to exist). They apparently didn't move to January 1st until a | |
year after they'd moved to the Gregorian calendar. | |
Anyway, that's all I've got for you. No moral. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From my understanding human calendars are attempts to approximate the travel of heavenly bodies (sun, moon, earth) relative to each other. Doesn't it make sense to adjust each month then according to the actual number of days (rotations of earth on its axis) by time it takes for the moon to rotate around the earth rounded appropriately (up by one on half)? Thereby months would slide relative to years, but we would also need seasons which would be the rounded number of days to cycle from Tropic of Capricorn to the Tropic of Cancer.
Of course, this would be confusing for the lay person as calendars would change every year.