[phobos] datetime review
Jonathan M Davis
jmdavisProg at gmx.com
Tue Oct 12 14:14:29 PDT 2010
On Tuesday, October 12, 2010 13:31:02 Michel Fortin wrote:
> How niche it is, I wonder. If you're using dates from two centuries ago
> then you probably need support for Julian. Beyond that I don't really see
> a need. But I don't know either how much other calendars are still in use
> in other parts of the world... perhaps more than westerners are willing to
> admit.
>
> An interesting observation is that Mac OS X gives me the choice of which
> calendar to use to display dates across the system. In the Language & Text
> system preference pane, I have the choice between Gregorian, Buddhist,
> Coptic, Ethiopic, Ethiopic (Amete Alem), Hebrew, Indian National, Islamic,
> Islamic (Civil), Japanese, Persian, and Republic of China. Perhaps they
> added this capability just to look cool, or perhaps it was to satisfy a
> demand from their customers. Again, I don't know the answer.
>
> I know however that the niche feature of today can grow in the standard
> feature of tomorrow. Handling time zones was a niche feature once. Then
> every computer became interconnected and it became a must. Perhaps letting
> the user choose his calendar will become a standard part of software
> localization in a few years... it already is for Mac OS X.
The ISO standard is essentially the Proleptic Gregorian Calendar (proleptic in
this case meaning that it uses the Gregorian Calendar calculations for all of
time rather than just after the calendar was adopted). There are a few
differences between the ISO standard and the traditional Proleptic Gregorian
Calendar (like using year 0 for 1 B.C.), but it's essentially the same. Most of
the world uses the Gregorian Calendar (including places like China, suprisingly
enough). I don't know the exact list of countries where it's not used (it
wouldn't surprise me if at least part of the Middle East didn't use the
Gregorian Calendar for their normal time-keeping), but it's essentially the
international standard.
And if you're worried about historical dates, that just plain gets messy.
Different countries adopted the Gregorian Calendar at different times and in
different ways (Sweden even did it in a manner which got them a February 30th:
http://en.wikipedia.org/wiki/February_30th ). Historically, people didn't even
necessarily start the year on January 1st, so exactly what date a historical
date indicates can be a very tricky thing - far too much so for it to be
particularly sane to try and have a date/time library handle it. Java's calendar
library apparently uses the Gregorian Calendar for dates after its official
adoption and the Julian for before, but that's got to be a bit messy and doesn't
really solve the problem anyway.
I opted to keep it simple and implemented the Proleptic Gregorian Calendar
(essentially following ISO 8601: http://en.wikipedia.org/wiki/ISO_8601 ). That's
what Boost did as well, though for some reason, their stuff doesn't cover
anything before the year 1400. My code covers B.C. as well as A.D.
I'm sure that there are applications which care about calendars other than the
Gregorian Calendar, but I really do think that it's a niche need. As part of
making the world interconnect better, a lot of this sort of thing is
increasingly being standardized, so I would expect alternate calendars to
actually be needed less rather than more.
- Jonathan M Davis
More information about the phobos
mailing list