Whole file
kellyjonbrazil/jc
The author described this change as “fix time parser for missing centiseconds”. It counts as a record because the check below fails on the code as it stood at e9ccedf0d and passes on 1c09289d9, with nothing else changed between the two runs.
Projectkellyjonbrazil/jc
Fix saved2025-03-31
Sharing licenceMIT · LICENSE.md
Change size+9 −4
What the code was meant to do, written into the code itself as a save note
fix time parser for missing centiseconds
The change
| 132 | 132 | ||
| 133 | 133 | class info(): | |
| 134 | 134 | """Provides parser metadata (version, author, etc.)""" | |
| 135 | - | version = '1.4' | |
| 135 | + | version = '1.5' | |
| 136 | 136 | description = '`/usr/bin/time` command parser' | |
| 137 | 137 | author = 'Kelly Brazil' | |
| 138 | 138 | author_email = 'kellyjonbrazil@gmail.com' | |
| ⋯ | |||
| 171 | 171 | proc_data['command_being_timed'] = proc_data['command_being_timed'][1:-1] | |
| 172 | 172 | ||
| 173 | 173 | if 'elapsed_time' in proc_data: | |
| 174 | - | proc_data['elapsed_time'] = proc_data['elapsed_time'].replace('.', ':') | |
| 175 | - | *hours, minutes, seconds, centiseconds = proc_data['elapsed_time'].split(':') | |
| 176 | - | proc_data['elapsed_time'] = proc_data['elapsed_time'][::-1].replace(':', '.', 1)[::-1] | |
| 174 | + | *hours, minutes, ss = proc_data['elapsed_time'].split(':') | |
| 175 | + | if '.' in ss: | |
| 176 | + | seconds, centiseconds = ss.split('.') | |
| 177 | + | else: | |
| 178 | + | seconds = ss | |
| 179 | + | centiseconds = '0' | |
| 180 | + | ||
| 177 | 181 | if hours: | |
| 178 | 182 | proc_data['elapsed_time_hours'] = jc.utils.convert_to_int(hours[0]) | |
| 179 | 183 | else: | |
| 180 | 184 | proc_data['elapsed_time_hours'] = 0 | |
| 185 | + | ||
| 181 | 186 | proc_data['elapsed_time_minutes'] = jc.utils.convert_to_int(minutes) | |
| 182 | 187 | proc_data['elapsed_time_seconds'] = jc.utils.convert_to_int(seconds) | |
| 183 | 188 | proc_data['elapsed_time_centiseconds'] = jc.utils.convert_to_int(centiseconds) | |
The check that tells the two apart
fail→pass·tests/test_time.py::MyTests::test_time_no_centiseconds
Check file tests/test_time.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 ite9ccedf0d7a745a41f4101199433378a26cb1e38
Broken version dated2025-03-30
Modulejc.parsers.time
Units changed_process, info
Fingerprint60308fb45e8463f5
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 kellyjonbrazil/jc
- 2026-03-25parse
- 2026-03-25_process
- 2025-04-02Fix broken controller parser schema to include power state prop (#652)
- 2025-03-31parse
- 2024-10-18Fix broken controller regexp scheme in the bluetoothctl parser (#599)
- 2024-09-07fix uptime for "user" instead of "users"