technology from back to front

Date and Time libraries in various languages

Can a correct, or even sensible Date, Time and Calendar library be designed, for any programming language at all, ever, by anybody, genius, time expert, or not? Certainly [old link: http://java.sun.com/j2se/1.4.2/docs/api/java/util/Date.html ] Java’s Date API isn’t very inspiring, but some systems do manage to do better: here’s a quick survey of the state of Date/Time/Calendar libraries in a few different languages.

* Scheme’s SRFI 19 is, overall, an excellent library at its core (i.e. the specification of Time objects), but suffers from a number of bugs in its reference implementation, some quite serious, and lacks support for the timezone database.

* Things may be looking up for Time processing in Java: the Joda Time library looks like it’s designed around the key separation of Instants, Intervals, and Durations from Calendar-related notions such as Dates, Times, and human-readable representations of time. The evidence suggests it may even deal with timezones properly.

* Even C’s venerable time implementation (it’s an int! Everything’s an int!) is better than that provided by many languages. At least it’s correct and reasonably simple. The main flaw in it is the way that the current timezone is not even a global variable – it’s an environment variable. Trying to treat it as a parameter is an exercise in frustration, making timezone calculations far, far more difficult than they need to be.

* Squeak currently has two major libraries: Chronology, the incumbent, and the comprehensive-looking newcomer Chronos. I’ve only ever used Chronology, but I can definitely say it was a very pleasant experience compared to every other language and date/time library I’ve ever used. Chronology doesn’t really do timezones (or leap seconds), and from that point of view Chronos is a significant improvement. Chronos looks very promising, but loading it broke my image (timestamping doits broke during save and quit) so I’ve not explored it in any detail.

by
tonyg
on
05/05/06
  1. See also (Common Lisp).

  2. From your description of your experience with Chronos in Squeak, it appears you have loaded the version on SqueakSource. That version is the very, very preliminary port of Chronos to Squeak done by Avi Bryant. It has many problems–as explained in this blog post: http://chronos-st.blogspot.com/2006/02/preliminary-port-of-chronos-to-squeak.html

    But there is a much newer version of Chronos available for Squeak, which doesn’t have the problems that were in Avi’s initial port. You can dowload it from the Chronos web site: http://www.chronos-st.org

    –Alan

  3. Thank you, Alan, I’ll give it a try.

 
 


nine − = 2

2000-14 LShift Ltd, 1st Floor, Hoxton Point, 6 Rufus Street, London, N1 6PE, UK+44 (0)20 7729 7060   Contact us