Skip to content
Myr

parser.patch

This file

Path

examples/datekit/layers/maintainers/known-bad/parser.patch

19 lines · 710 bytes

Last changed by

Merge build/608-datekit-maintainers-layer: datekit has a maintainers layer of sealed checks, each citing the clause it enforces, and the seed pushes itoscabrielbefore adoption166f6c9

History of this file

Take it

Merge build/608-datekit-maintainers-layer: datekit has a maintainers layer of sealed checks, each citing the clause it enforces, and the seed pushes itoscabrielbefore adoption166f6c9

lines 1–19why, one step back
1parser: round the digits past the millisecond
23parseISO reads 14:30:15.9999 as 14:30:16.000, carrying into the next4second, where the README says those digits are dropped. The public5tests pass; admission needs a held-back check in parser to fail here.67diff --git a/src/parse.ts b/src/parse.ts8index 0ed8e1a..f4bb9c7 1006449--- a/src/parse.ts10+++ b/src/parse.ts11@@ -104,7 +104,7 @@ const readTime = (text: string): number | undefined => {12 }13 14 // Digits past the millisecond are dropped, not rounded.15- const millisecond = whole((groups.fraction ?? "").padEnd(3, "0").slice(0, 3));16+ const millisecond = Math.round(Number(`0.${groups.fraction ?? "0"}`) * 1000);17 18 return (19 hour * MS_PER_HOUR +