From CommonJS Spec Wiki
(Redirected from ServerJS/DateTime)
Jump to: navigation, search

Date and Time

EcmaScript already supports a wide range of functions handling Date, see

but those kind of setters/getters are not very convinient when working with DateTimes. an easy way to e.g. add/substract timeranges, calculate time-diffs, etc. would be beneficial.

problems to solve

  • outputting / parsing datetime
  • date calculations / manipulating
  • json date extension (see crockford's json module)?

including TZ conversion? naive datetime's - not knowing about TZ - are easier to handle, though it seems JS has native aware datetime objects. utc & localtime.

Prior Art


// Get today’s date;
// Add 5 days to today;
// Get Friday of this week
// Get March of this year
// Is today Friday?;  // true|false
  • and ( is obsoleted by ES5)
    • provides convenience methods
    • provides format and parse functions which are data driven off the Unicode CLDR project, fully localized client-side, downloading localizations only as needed. Support for hundreds of languages/variants.
>>>, {selector: “date”, formatLength:long}) // en-us
 “June 28, 2008″
>>>, {selector: “date”, formatLength:long}) // zh-cn2008628日”
    • has experimental support for non-Gregorian calendars as well as Unix- and PHP-style formatting.
  • Matthew Eernisse implemented a Date-like class in JS to deal with the Olson table client-side, as well as code to parse and preprocess the Olson table.
  • ...