One function
date_convert in r1chardj0n3s/parse
The author described this change as “fix bug in PM time overflow closes issue #16”. It counts as a record because the check below fails on the code as it stood at 95856f4e1 and passes on 4cf2b44bc, with nothing else changed between the two runs.
Projectr1chardj0n3s/parse
Fix saved2013-10-15
Sharing licenceMIT · LICENSE
Change size+7 −0
What the code was meant to do, written into the code itself as a docstring
Convert the incoming string containing some date / time info into a datetime instance.
The change
| 33 | 33 | H = int(H) | |
| 34 | 34 | M = int(M) | |
| 35 | 35 | ||
| 36 | + | day_incr = False | |
| 36 | 37 | if am is not None: | |
| 37 | 38 | am = groups[am] | |
| 38 | 39 | if am and am.strip() == 'PM': | |
| 39 | 40 | H += 12 | |
| 41 | + | if H > 23: | |
| 42 | + | day_incr = True | |
| 43 | + | H -= 24 | |
| 40 | 44 | ||
| 41 | 45 | if tz is not None: | |
| 42 | 46 | tz = groups[tz] | |
| ⋯ | |||
| 70 | 74 | m = MONTHS_MAP[m] | |
| 71 | 75 | d = int(d) | |
| 72 | 76 | d = datetime(y, m, d, H, M, S, u, tzinfo=tz) | |
| 77 | + | ||
| 78 | + | if day_incr: | |
| 79 | + | d = d + timedelta(days=1) | |
| 73 | 80 | ||
| 74 | 81 | return d | |
The check that tells the two apart
fail→pass·test_parse.py::TestBugs::test_pm_overflow_issue16
Check file test_parse.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it95856f4e1e8bb36fc2858c4d2e81a369ff925f21
Broken version dated2013-10-15
Moduleparse
Units changeddate_convert
Fingerprintfef85f3fd93337bb
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in r1chardj0n3s/parse
- 2021-06-04Fix handling of unused alignment (#132)
- 2020-07-30findall
- 2019-12-23Handle fortran formatted float number, Bug fix & test case.
- 2012-09-29fix type conversion error with dotted names