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

Method checkParts

parse.js:112–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

110 }
111
112 checkParts() {
113 // months: 0-indexed, 0–11 are valid
114 if(this.month < 0 || this.month > 11) {
115 throw new Error(`Unsupported date format (invalid month): ${this.source}`);
116 }
117
118 // check if days are too big
119 if(this.day < 1 || new Date(Date.UTC(this.year, this.month, 1)).getUTCMonth() !== new Date(Date.UTC(this.year, this.month, this.day)).getUTCMonth()) {
120 throw new Error(`Unsupported date format (invalid days for month): ${this.source}`);
121 }
122 }
123}
124
125/** @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 */

Callers 1

parseMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected