Commit f99c46c
committed
feat(core): widen the date/time parse grammar to .NET's (#1929 rows 1 and 3)
Decided by the user on 2026-08-18: widen all four of #1929's recorded respects.
Row 2 (a fractional second at 100-ns precision) already landed with rows 5-6 on
2026-08-01. Row 4 is the DateTimeKind and ParseExact surface and stays open as
#1941 and #1939. This is rows 1 and 3.
Row 1 the MONTH and DAY admit one or two digits, so "2024-6-15" parses.
Row 3 the OFFSET is .NET's ParseTimeZone grammar, so "+8", "+2:5", "+800"
and "+0800" join "+02:05".
It is a PURE WIDENING. No string that parsed before parses differently or fails
now, so there is no source break, no signature change, no layout change and
nothing for a caller to migrate -- only a note that text .NET accepts is now
accepted here too. Landed under SA-5.
Both halves are transcribed, not guessed.
* .NET's lexer types a digit run of one or two as a NumberToken and three or
more as a YearNumberToken (Globalization/DateTimeParse.cs:5593-5605), so
"2024-6-15" produces exactly the token sequence "2024-06-15" produces and
reaches the same year-month-day terminal state.
* ParseTimeZone (DateTimeParse.cs:530-556) reads ONE digit run after the sign:
length 1-2 is an hour, optionally followed by ':' and a 1-2 digit minute;
length 3-4 is split `value / 100` and `value % 100`. That integer split is
WHY "+800" and "+0800" agree, and why "+205" means 125 minutes. A minute
field of 60 or more is rejected, which is .NET's only check there
(DateTimeParse.cs:565-568).
Two stops are deliberate and both are pinned.
* The YEAR is not widened. .NET would read a short one through
Calendar.ToFourDigitYear, whose century window is culture state this port has
no way to carry, so "24-06-15" stays a failure rather than silently landing in
a century nobody chose.
* The +/-14h bound stays on DateTimeOffset and does NOT move into the shared
grammar, because that is where .NET puts it: ParseTimeZone permits an hour up
to 99 and the MinOffset/MaxOffset test runs later, at the two sites that
actually STORE an offset (DateTimeParse.cs:2777,2875). System::DateTime parses
an offset and discards it -- it has no DateTimeKind -- so it must not inherit a
bound on a value it never keeps. DateTime::TryParse("...+99") succeeds and
DateTimeOffset::TryParse("...+99") fails, and one test pins both halves of that
sentence.
THE WIDENING FORCED A STRUCTURAL REPAIR THE TICKET DID NOT NAME.
DateTimeOffset::TryParse copied its input into a std::string, searched for a '+' or
'-' starting at CHARACTER 10, and handed the prefix to DateTime::TryParse. That
split is correct only while the date part is exactly ten characters wide, and
"2024-6-5" is eight -- so the search was about to start inside the date, or, for a
bare short date, past the end, which the `input.size() < 10` precheck was quietly
standing in for. The three doors now share one grammar in
System/detail/DateTimeTextScanner.hpp. They had drifted apart precisely because
they did not.
Ten existing pins are inverted in place, six cases added:
SharpRuntimeTests_Core_Base 6,019 -> 6,025. Two of the inverted ones are worth
naming. Ccf002_UnpaddedOffsetRejectionIsANarrowingNotAParityFix recorded that
#1879's rejection of "+2:5" was a NARROWING and not a parity fix, since .NET reads
it as 125 minutes -- the value this port already produced. It now pins the
agreement itself, which is what it was always about.
Nine mutations, all caught: month/day back to two digits (shared grammar, and
DateOnly's own copy, separately); dropping the minute<60 check; swapping the
hour/minute split of a 3-4 digit run; treating a 3-digit run as an hour;
ignoring the minus sign; moving the +/-14h bound into the shared grammar;
restoring the `size() < 10` precheck; letting the offset run reach five digits;
widening the year to 1-4 digits.
Downstream, measured per SA-2 condition 5: neither cna nor mobile-eggbert calls
DateTime/DateTimeOffset/DateOnly Parse or TryParse at all -- zero sites in both.
Neither repository was modified. A widening could not have changed their answers
in any case.
Gate: 17,296 run, 17,296 passed, 0 failed, 0 skipped across 38 executables,
GREEN, confirmed by two consecutive full runs.
docs/Migration-DateTimeGrammarWidening.md1 parent fb69aa8 commit f99c46c
10 files changed
Lines changed: 511 additions & 148 deletions
File tree
- docs
- modules/core
- include/System/detail
- src/System
- tests/System
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
Lines changed: 128 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
77 | | - | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
106 | 108 | | |
107 | 109 | | |
108 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
109 | 233 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
182 | 187 | | |
183 | 188 | | |
184 | 189 | | |
185 | | - | |
186 | | - | |
| 190 | + | |
| 191 | + | |
187 | 192 | | |
188 | 193 | | |
189 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
413 | | - | |
| 413 | + | |
414 | 414 | | |
415 | | - | |
| 415 | + | |
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
422 | | - | |
423 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
424 | 430 | | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
445 | 434 | | |
446 | 435 | | |
447 | 436 | | |
448 | 437 | | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
453 | 444 | | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
458 | 448 | | |
459 | 449 | | |
460 | 450 | | |
461 | 451 | | |
462 | 452 | | |
463 | 453 | | |
464 | | - | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
465 | 457 | | |
466 | 458 | | |
467 | 459 | | |
| |||
0 commit comments