While DateJS allows you to do math, there’s also a nice little hack you can do for at least one simple use case: given a date, what are the next and previous months?
In good APIs this is handled with ease:
It’s not the same result, but that’s okay because the day is unnecessary. I’ve tested it in Rhino and a few browsers (FF, Chrome, IE 8) and all had the same result. Hope it helps.
 JDK 8 will vastly improve the default, taking it from terrible to awesome – see JSR 310.
 The ‘advance’ function is not in the core Ruby Date/DateTime library, but it is added by Rails. I had a devil of a time getting this to run as a standalone script so just ran it in the rails console. The interplay between the names of Ruby libraries, the classes, and the documentation is very confusing to an outsider – for example, ‘ri DateTime’ gives you methods monkeypatched into the class by ActiveSupport.