rezemika / humanized_opening_hours

A parser for the opening_hours fields from OpenStreetMap
GNU Affero General Public License v3.0
26 stars 20 forks source link

Max recursions error in next_change() function #31

Closed rooholam closed 5 years ago

rooholam commented 5 years ago

It happens with Su off;Tu-Fr off;Sa 15:00-20:00;Mo 15:00-20:00

....
    return _current_or_next_timespan(new_dt, i=i+1)
  File "/home/ramin/workspace/map/POI/humanized_opening_hours/main.py", line 522, in _current_or_next_timespan
    return _current_or_next_timespan(new_dt, i=i+1)
  File "/home/ramin/workspace/map/POI/humanized_opening_hours/main.py", line 519, in _current_or_next_timespan
    new_dt.date()+datetime.timedelta(i),
OverflowError: date value out of range

seems that Tu-Fr off is selected here: https://github.com/rezemika/humanized_opening_hours/blob/6016a00908dc7a9a0646205f754077bcb9a7a7ea/humanized_opening_hours/main.py#L500

it is fixed changing this line:

https://github.com/rezemika/humanized_opening_hours/blob/6016a00908dc7a9a0646205f754077bcb9a7a7ea/humanized_opening_hours/main.py#L664

to:

if matching_rules and matching_rules[0].status != 'closed':
rezemika commented 5 years ago

Thank you for your feedback!

It's solved by the commit d249acd. I'll push a new version soon on PyPi. :)