MCPcopy Create free account
hub / github.com/denoland/std / parseDate

Function parseDate

http/unstable_structured_fields.ts:1014–1030  ·  view source on GitHub ↗
(state: ParserState)

Source from the content-addressed store, hash-verified

1012}
1013
1014function 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
1032function parseDisplayString(state: ParserState): BareItem {
1033 if (consume(state) !== "%") {

Callers 1

parseBareItemFunction · 0.85

Calls 2

consumeFunction · 0.85
parseIntegerOrDecimalFunction · 0.85

Tested by

no test coverage detected