[phobos] datetime review

Michel Fortin michel.fortin at michelf.com
Tue Oct 12 13:31:02 PDT 2010


Le 2010-10-12 à 15:37, Yao G. a écrit :

> On Tue, 12 Oct 2010 14:19:51 -0500, Michel Fortin <michel.fortin at michelf.com> wrote:
> 
>> For a date system that does support multiple calendars very well, take look at the Cocoa dates. Cocoa has NSDate which is basically a timestamp, NSDateComponents which contains a list of components for calendar dates and time of day, and the NSCalendar class that converts between the two.
> 
> Another good library that's calendar-agnostic is the Joda Time. It has several chronologies (calendars), like ISO8601, buddhist, coptic, ethiopic, gregorian, islamic, etc., that can be plugged dynamically. It's a very comprehensive library.
> 
> http://joda-time.sourceforge.net/

Nice. I didn't know about this one.


> However. I don't think is that useful to have support for multiple calendars. I mean it's a cool thing to have, but honestly, how many programmers actually use Julian or Coptic calendars? It's a very niche usage of date and time programming constructs.

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.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/





More information about the phobos mailing list