(state: ParserState)
| 1012 | } |
| 1013 | |
| 1014 | function parseDate(state: ParserState): BareItem { |
| 1015 | if (consume(state) !== "@") { |
| 1016 | throw new SyntaxError( |
| 1017 | `Invalid structured field: expected '@' at position ${state.pos - 1}`, |
| 1018 | ); |
| 1019 | } |
| 1020 | |
| 1021 | const intItem = parseIntegerOrDecimal(state); |
| 1022 | if (intItem.type !== "integer") { |
| 1023 | throw new SyntaxError( |
| 1024 | "Invalid structured field: date must be an integer", |
| 1025 | ); |
| 1026 | } |
| 1027 | |
| 1028 | const value = new Date(intItem.value * 1000); |
| 1029 | return { type: "date", value }; |
| 1030 | } |
| 1031 | |
| 1032 | function parseDisplayString(state: ParserState): BareItem { |
| 1033 | if (consume(state) !== "%") { |
no test coverage detected