ValueError: hour must be in 0..23
maethub opened this issue Β· comments
Hi all,
First of all, thanks for all the people working on this! I am very happy this project exists π
Error
In the last few days, I ran into an issue when parsing a fit-file from Garmin.
...
File "/Users/mb/repos/fitparser/venv/lib/python3.9/site-packages/fitparse/processors.py", line 44, in run_type_processor
self._run_processor(self._scrub_method_name(
File "/Users/mb/repos/fitparser/venv/lib/python3.9/site-packages/fitparse/processors.py", line 62, in _run_processor
getattr(self, processor_name)(data)
File "/Users/mb/repos/fitparser/venv/lib/python3.9/site-packages/fitparse/processors.py", line 89, in process_type_localtime_into_day
field_data.value = datetime.time(h, m, s)
ValueError: hour must be in 0..23
With a bit of debugging, I traced the error to a record within "user_profile". The field "sleep_time" had a value of 86400, which leads to the following call:
datetime.time(24, 0, 0)
in this method: (
python-fitparse/fitparse/processors.py
Line 84 in af4cf3a
which generates the above error.
Versions
My setup is the following:
- fitparser: 1.2.0
- python: 3.9.7
Possible Solution
I created a fork with a possible fix: quevita2018@6ea3718
But honestly, I am not completely sure whether this is the cleanest way to handle this...
Thanks for your help!
Cheers,
Mathias
@maethub the best way would be to open a draft PR from your commit, and link this issue to it. That way people can easily review what changed, and provide feedback.
@fundthmcalculus Yes, thanks.
I hope PR #138 can be of any help.