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

Function serializeDate

http/unstable_structured_fields.ts:1366–1375  ·  view source on GitHub ↗
(value: Date)

Source from the content-addressed store, hash-verified

1364}
1365
1366function serializeDate(value: Date): string {
1367 const timestamp = Math.floor(value.getTime() / 1000);
1368 if (!Number.isFinite(timestamp)) {
1369 throw new TypeError("Invalid date");
1370 }
1371 if (timestamp < -MAX_INTEGER || timestamp > MAX_INTEGER) {
1372 throw new TypeError("Date out of range");
1373 }
1374 return `@${timestamp}`;
1375}
1376
1377function serializeDisplayString(value: string): string {
1378 const bytes = UTF8_ENCODER.encode(value);

Callers 1

serializeBareItemFunction · 0.85

Calls 1

floorMethod · 0.80

Tested by

no test coverage detected