Found out about this nifty date package for JavaScript today: Datejs. Its chainable interface makes the code read very naturally:
// What date is next thursday?
Date.today().next().thursday();
// Add 3 days to Today
Date.today().add(3).days();
// Is today Friday?
Date.today().is().friday();
It also does quite a bit of natural English parsing, like Date.parse(‘next thursday’), although most date libraries support that too. I think the chainable interface stands out here as something special. Let's contrast that with some perl code to calculate yesterday, shall we??
my @lt = localtime(time - 86400);
return ($lt[5]+1900) .'-' . ($lt[4]+1) . '-' . ($lt[3]);
(Disclaimer: I didn't actually write that, but it's in a legacy app I sometimes maintain. I'm sure there is a cleaner way in perl to write that code, I just wouldn't know it, nor do I care to!)

Re: Datejs - A JavaScript Date Library
posted by Geoffrey McGill on Wednesday Dec 5th, 2007 at 1:47a.m.
Hi Kumar, Thanks for the post regarding Datejs. We really appreciate your interest and feedback. We're working hard on the library and constantly making improvements.
Ah. That chuck of Perl is some sweet code. Here's the Datejs equivalent.
Date.today().add(1).day();
I've been thinking of adding .yesterday() and .tomorrow() to the list of functions as well. If added the above code could be shortened to the following.
Date.tomorrow(); // <-- how sweet is that?
Anywho, thanks again and keep on blog'n.
Re: Datejs - A JavaScript Date Library
posted by Rannjit on Tuesday Jul 21st, 2009 at 7:09a.m.
This is Ranjit