MCPcopy Index your code
hub / github.com/11ty/parse-date-strings / parse

Method parse

parse.js:79–90  ·  view source on GitHub ↗

@param {string} str An [RFC 9557](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/PlainDateTime#rfc_9557_format)-compatible string

(str)

Source from the content-addressed store, hash-verified

77
78 /** @param {string} str An [RFC 9557](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/PlainDateTime#rfc_9557_format)-compatible string */
79 static parse(str) {
80 let parts = IsoDateParts.getParts(str);
81 if(parts) {
82 let iso = new IsoDate(parts);
83 iso.source = str;
84 iso.checkParts();
85
86 return new Date(Date.UTC(...iso.getArgs()));
87 }
88
89 throw new Error(`Unsupported date format: ${str}`);
90 }
91
92 /**
93 * @param {object} parts

Callers 1

parseFunction · 0.80

Calls 3

checkPartsMethod · 0.95
getArgsMethod · 0.95
getPartsMethod · 0.80

Tested by

no test coverage detected