(value: string)
| 55 | |
| 56 | /** Parses an ISO 8601 date string, with no time components. */ |
| 57 | export function parseDate(value: string): CalendarDate { |
| 58 | let m = value.match(DATE_RE); |
| 59 | if (!m) { |
| 60 | if (ABSOLUTE_RE.test(value)) { |
| 61 | throw new Error(`Invalid ISO 8601 date string: ${value}. Use parseAbsolute() instead.`); |
| 62 | } |
| 63 | throw new Error('Invalid ISO 8601 date string: ' + value); |
| 64 | } |
| 65 | |
| 66 | let date: Mutable<CalendarDate> = new CalendarDate( |
| 67 | parseNumber(m[1], 0, 9999), |
| 68 | parseNumber(m[2], 1, 12), |
| 69 | 1 |
| 70 | ); |
| 71 | |
| 72 | date.day = parseNumber(m[3], 1, date.calendar.getDaysInMonth(date)); |
| 73 | return date as CalendarDate; |
| 74 | } |
| 75 | |
| 76 | /** Parses an ISO 8601 date and time string, with no time zone. */ |
| 77 | export function parseDateTime(value: string): CalendarDateTime { |
no test coverage detected