isodate
isodate copied to clipboard
parse_date behavior change in version 0.7.2
Hello,
I noticed a change in the way parse_date works in the last release. Previously, using parse_date with a datetime string worked, returning only the date part :
>>> import isodate
>>> dt = '2024-10-11T13:00:00'
>>> isodate.parse_date(dt)
datetime.date(2024, 10, 11)
This was very useful when working with a module like FullCalendar which returns date strings OR datetime strings according to the view.
In the last version, this no longer works :
>>> import isodate
>>> dt = '2024-10-11T13:00:00'
>>> isodate.parse_date(dt)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Env\Pyramid_crit_py312\Lib\site-packages\isodate\isodates.py", line 194, in parse_date
raise ISO8601Error("Unrecognised ISO 8601 date format: %r" % datestring)
isodate.isoerror.ISO8601Error: Unrecognised ISO 8601 date format: '2024-10-11T13:00:00'
The cause being the new "add_re" function which adds "\A" and "\Z" at the start and end of the regexes.
def add_re(regex_text):
cache_entry.append(re.compile(r"\A" + regex_text + r"\Z"))
Removing the "\Z" fixes the issue.
Maybe this is intentional, though...
Thanks a lot