MCPcopy Create free account
hub / github.com/11ty/parse-date-strings / parseDateTime

Function parseDateTime

test/temporal.js:22–36  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

20}
21
22export function parseDateTime(str) {
23 let d;
24 if(str.endsWith("Z") || str.match(TIMEZONE_REGEX)) {
25 d = Temporal.Instant.from(str, {
26 overflow: "reject"
27 });
28 } else {
29 d = Temporal.PlainDateTime.from(str, {
30 overflow: "reject"
31 });
32 }
33
34 let timestamp = convertTemporalToTimestamp(d);
35 return new Date(timestamp).toUTCString();
36}
37
38export function parse(str) {
39 let result;

Callers 1

parseFunction · 0.85

Calls 1

Tested by

no test coverage detected