better@nform.ca  | 1.800.670.7025
Blog

Datejs: Designing for developers

by Gene Smith
December 5, 2007

Our friend Geoff McGill has developed a new open-source Javascript library, Datejs, for handling dates. Normally this wouldn't be the kind of thing I'd blog about, but Geoff's done an excellent job designing the library so that it's usable. That's right, computer languages and software libraries can be designed just like anything else. Good design makes programming easier, less error prone and more fun.

I'll touch on two interesting features of Datejs. First, its syntax is natural, in the sense that you can write code almost like you'd write a sentence. You can see from the examples below, like (3).days().ago(), that the syntax matches the way we think about dates.

Datejs Synyax

Second (and this has as much impact on users as developers), it can parse just about any kind of date. I deliberately threw it an oddball date to see what it could do:

Parsing dates with datejs

Datejs handles it without a problem. Date entry can be a source of frustration for users ("do I use dd/mm/yyyy format? or mm/dd/yy?") and it's great to see people developing software that automagically handles these problems.

(Datejs has already received some nice write-ups from Ajaxian and Wired.)

blog comments powered by Disqus