ServerJS/DateTime: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(→‎Prior Art: better link with more examples)
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
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 ==

Revision as of 09:32, 22 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

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

Date.diff
Date.getTimespan
Date.equals 
// 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