A Javascript date library
datejs.com
datejs.com
Other posters have had other complaints about missing functionality--some struck me as reasonable, some not so much--but I haven't kept track.
http://home.jongsma.org/software/js/datepicker
This is the .js file:
It seems unusual that "next June" and "last June" both pick the 4th of the month (today's date); but just "June" gives the 1st of the month.
Also "next June" gives "Friday, June 04, 2010 12:00:00 AM" so it picks the day of the month based on today; but the time of day doesn't depend on the time now.
(pseudo) Date d = new Date('1/31/2009'); d.addOneMonth();
What is the value of d? 2/28/09? 3/2/09? 2/25/09?
Writing a date library is not for the fainthearted.
This is a major personal hobby-horse of mine, and I don't know of a library that does all of what I want by default. The constructor for datetime in Python's standard library comes very close:
datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])
All of the time components have no implied precision beyond the input you've given -- "2009-06-04 3pm" is never implicitly upcast into "2009-06-04 15:00:00 UTC". This is awesome.Unfortunately the date object used internally does not allow for partial precision, so datetime doesn't expose it.
Not really a useful thing to know but I wanted to post it anyhow.
Date.today().add(3).days();
Be even better if it let you leave off the brackets like ruby, but oh well.