(text: string)
| 625 | |
| 626 | /** Parses a trailing time zone into seconds east of UTC. */ |
| 627 | const parseZone = (text: string): number => { |
| 628 | const match = zoneRegex.exec(text) |
| 629 | if (match === null) { |
| 630 | return fail(`Expected a time zone offset, received "${text}"`) |
| 631 | } |
| 632 | if (match[1] === undefined) return 0 |
| 633 | const minutes = match[3] === undefined ? 0 : Number(match[3]) |
| 634 | const trailingSeconds = match[4] === undefined ? 0 : Number(match[4]) |
| 635 | const seconds = Number(match[2]) * 3600 + minutes * 60 + trailingSeconds |
| 636 | if (minutes > 59 || trailingSeconds > 59 || seconds >= TZDISP_LIMIT_SECONDS) { |
| 637 | return fail(`Time zone offset out of range, received "${text}"`) |
| 638 | } |
| 639 | return match[1] === "-" ? -seconds : seconds |
| 640 | } |
| 641 | |
| 642 | const formatZone = (secondsEast: number): string => { |
| 643 | const sign = secondsEast < 0 ? "-" : "+" |
no test coverage detected