-
-
Save coffeemug/6168031 to your computer and use it in GitHub Desktop.
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. |
There is a moral:
- Store timestamps for computers and developers as either RFC3339/ISO8601 or time_t. Both boil down to representing seconds ± an epoch, as even the ostensibly human-parseable string algorithmically extends the Gregorian calendar to all time.
- Display timestamps for humans using the calendar support in the best localization library you have available.
Yes, this doesn't solve every theoretical problem: there are subtly varying ways of defining "seconds ± an epoch" and localization requires a concern for usability. The point is we already have what @Akku is asking for: sane and useful and standardized options for representing time along a simple number line (what programmers want), and converters from this pure ideal into the "deprecated" messiness of how people prefer to communicate in real life (what users deserve).
Why is this not a Wikipedia article? :)
+1 on @brandongalbraith comment. It should be a Wikipedia article, or part of one about dates.
@brandongalbraith, @chronossc -- Most of the information in there is cribbed from http://en.wikipedia.org/wiki/Gregorian_calendar , or else from more specific pages like http://en.wikipedia.org/wiki/Swedish_calendar or http://en.wikipedia.org/wiki/Dutch_Republic .
Interestingly, the Russian shooting team missed competing in the 1908 Olympics since they were following the "wrong" calendar. I've added that info on a fork at https://gist.github.com/dickfeynman/6178581 but dunno how to submit a pull request.
While Russia did change to the Gregorian calendar in 1918, they changed it to the Soviet calendar in 1929, but reverted in 1940. During the French Revolution, France used a Metric inspired calendar until 1805, when they went back to the Gregorian calendar. It was briefly reimplemented in 1871, during the Paris Commune. Both these calendars were based on a simplification of the months (both used 30 days for each month), which required some 'complementary days', that were added at the end of the year.
When Romulus (or so legend tells us) created the first Roman Calendar, there were no January and February (they were added by King Noma), hence why the year - according to Roman tradition - starts 1 March. Caesar was 15 days (ides) into the year's session when he was killed. I'd also like to point out that it is the 24th and not the 29th of February that is the leap day. In fact, originally, it was not a leap day, but a leap month, inserted near the end of February, called Mensis Intercalaris.[0] I realise the old Roman calendar might be a bit before the Gregorian calendar, but let's not forget that the Gregorian calendar is based on those.
In North Korea, while they use the Gregorian calendar, they do not use the regular reckoning, and all years are according to Kim Il-Song's birth year (that is, 1912). This is known as the Juche calendar. However, Gregorian years often appear after the Juche calendar year in official documents.
[0] I personally find this a bit unfair, as consuls served each month alternating for a year. So on leap years, you just get an extra month to govern of the other guy.
Bravo for implementing this :)
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.
@NSElvis, I'm sure each person's heartbeat is slightly different.