Commit bb4a3c1
Fix time-only DateTime.parse under freeze (#440)
* Fix time-only DateTime.parse under freeze
DateTime.parse('HH:MM') previously fell back to parsed_date + travel_offset_days,
with travel_offset_days = (@travel_offset / 86400).round. Because @travel_offset
measures the gap between the frozen moment and the real system clock, that rounding
stepped up or down depending on how close the real clock was to a 12‑hour boundary.
For example, freezing at 2017-08-10 10:00 UTC while the host clock is
2025-11-13 22:00 UTC yields an offset of N.5 days, so rounding adds an
extra day and parsing “01:00” returns 2017-08-09 instead of 2017-08-10.
Anchor hour/minute-only parses to the mocked year/month/day and add deterministic
regression tests to ensure time-only input no longer depends on the host clock.
* Rename tests for DateTime.parse HH:MM format
- test_date_time_parse_hhmm_uses_frozen_date_not_real_clock: regression test ensuring parsed time uses frozen date, not host clock
- test_date_time_parse_hhmm_format_returns_correct_time: basic HH:MM format parsing
* update test according to the PR comments konieczkow made
---------
Co-authored-by: Josh Cronemeyer <joshuacronemeyer@gmail.com>1 parent e4bba8c commit bb4a3c1
2 files changed
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
157 | 159 | | |
158 | 160 | | |
159 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
67 | 85 | | |
68 | 86 | | |
69 | 87 | | |
| |||
0 commit comments