loaders ยป datetime
datetime() โ Date
datetimeItems() โ array
datetimeList() โ array
Accepts a subset of ISO 8601 date/time formats described in this W3C note: https://www.w3.org/TR/NOTE-datetime
Returns a JavaScript Date
object (or throws an error for invalid values).
Some possible example values that match the format:
1990
1990-12
1990-12-31
1990-12-31T23:59Z
1990-12-31T23:59:00+01:00
1990-12-31T23:59:00.999+01:00
Note that spaces as separators are not allowed.
Development note: A more appealing, less technical datetime format or an additional loader to serve that requirement would be generally welcome, the current format is basically just an initial draft that should cover many usecases and is standardized through its ISO origin, feel free to get in touch and propose an extension/update if you'd be interested in such development.
enostart: 1992-12-01
end: 1994-03-04T13:14Z
invalid: 2018-03-14 13:10
javascriptconst document = eno.parse(input);
document.datetime('start'); // returns [object Date]
document.datetime('end'); // returns [object Date]
document.datetime('invalid');
// throws an error: 'invalid' must contain a valid date or date and time, for instance '1997-07-16' or '1994-11-05T13:15Z' (see https://www.w3.org/TR/NOTE-datetime).