ServerJS/DateTime: Difference between revisions
< ServerJS
Jump to navigation
Jump to search
(6 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
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. | 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 == | == Prior Art == | ||
Line 11: | Line 18: | ||
Date.equals | Date.equals | ||
* datejs, clientside library. nifty & big. http:// | * datejs, clientside library. nifty & big. http://code.google.com/p/datejs/ | ||
// Get today’s date | // Get today’s date | ||
Line 23: | Line 30: | ||
// Is today Friday? | // Is today Friday? | ||
Date.today().is().friday(); // true|false | Date.today().is().friday(); // true|false | ||
* [http://api.dojotoolkit.org/jsdoc/1.3/dojo.date dojo.date] and [http://api.dojotoolkit.org/jsdoc/1.3/dojo.date.locale dojo.date.locale] (dojo.date.stamp is obsoleted by ES5) | |||
** dojo.date provides convenience methods | |||
** dojo.date.locale provides format and parse functions which are data driven off the [http://unicode.org/cldr Unicode CLDR project], fully localized client-side, downloading localizations only as needed. Support for hundreds of languages/variants. | |||
>>> dojo.date.locale.format(myDate, {selector: “date”, formatLength: “long”}) // en-us | |||
“June 28, 2008″ | |||
>>> dojo.date.locale.format(myDate, {selector: “date”, formatLength: “long”}) // zh-cn | |||
“2008年6月28日” | |||
** [http://api.dojotoolkit.org/jsdoc/1.3/dojox.date dojox.date] has experimental support for non-Gregorian calendars as well as Unix- and PHP-style formatting. | |||
* Matthew Eernisse implemented a [http://js.fleegix.org/plugins/date/date Date-like class] in JS to deal with the Olson table client-side, as well as code to parse and preprocess the Olson table. | |||
* ... |
Latest revision as of 00:01, 23 June 2009
Date and Time
EcmaScript already supports a wide range of functions handling Date, see https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Date
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
- helma NGs, minimal date extensions. http://github.com/hns/helma-ng/blob/8077ce9636d33d1ce678f52698470b4d5316841c/modules/core/date.js
Date.diff Date.getTimespan Date.equals
- datejs, clientside library. nifty & big. http://code.google.com/p/datejs/
// Get today’s date Date.today(); // Add 5 days to today Date.today().add(5).days(); // Get Friday of this week Date.friday(); // Get March of this year Date.march(); // Is today Friday? Date.today().is().friday(); // true|false
- dojo.date and dojo.date.locale (dojo.date.stamp is obsoleted by ES5)
- dojo.date provides convenience methods
- dojo.date.locale 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.
>>> dojo.date.locale.format(myDate, {selector: “date”, formatLength: “long”}) // en-us “June 28, 2008″
>>> dojo.date.locale.format(myDate, {selector: “date”, formatLength: “long”}) // zh-cn “2008年6月28日”
- dojox.date 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.
- ...