Commit f533006
committed
Fix start_of("day") landing on the previous day when a zone springs forward at midnight
_start_of_day resets to midnight via self.at(0, 0, 0, 0), which propagates the
receiver's fold. On a timezone that springs forward exactly at midnight (e.g.
Chile/Continental, where 2025-09-07 00:00:00 does not exist), reaching that day
through .add(days=1) yields fold=0. For a nonexistent (skipped) local time with
fold=0, the timezone resolver shifts the instant backward, so midnight lands at
23:00 on the previous day and start_of("day") is wrong and non-idempotent.
After resetting to midnight, if the calendar day changed then midnight was
skipped, so re-create the day's first valid instant resolving forward (fold=1).
The guard fires only when midnight actually moved to the previous day, so all
other zones/dates are byte-identical (verified against UTC, America/New_York,
Asia/Tokyo, Europe/London, Europe/Vienna's 02:00 gap, and America/Sao_Paulo's
midnight fall-back). start_of("week") is covered via delegation.
Fixes #915.1 parent 5ad098b commit f533006
2 files changed
Lines changed: 28 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
826 | 826 | | |
827 | 827 | | |
828 | 828 | | |
829 | | - | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
830 | 842 | | |
831 | 843 | | |
832 | 844 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
0 commit comments