| 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 */ |