adafruit / Adafruit_CircuitPython_datetime

Basic date and time types. Implements a subset of the CPython datetime module.
MIT License
4 stars 9 forks source link

Support more iso formats like python 11 #22

Open Neradoc opened 1 year ago

Neradoc commented 1 year ago

This library:

>>> from adafruit_datetime import datetime
>>> datetime.fromisoformat('2000-01-01T00:30:27Z')
Traceback (most recent call last):
  File "adafruit_datetime.py", line 1019, in fromisoformat
  File "adafruit_datetime.py", line 985, in _parse_iso_string
ValueError: 

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "adafruit_datetime.py", line 1386, in fromisoformat
  File "adafruit_datetime.py", line 1027, in fromisoformat
ValueError: Invalid isoformat string: '00:30:27Z'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "adafruit_datetime.py", line 1391, in fromisoformat
ValueError: Invalid isoformat string: '2000-01-01T00:30:27Z'
>>> 

Python 11:

❯ python
Python 3.11.1 (main, Jan  5 2023, 23:03:26) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> datetime.fromisoformat("2022-01-01T00:01:00Z")
datetime.datetime(2022, 1, 1, 0, 1, tzinfo=datetime.timezone.utc)
>>>
skjdghsdjgsdj commented 1 month ago

I have run into this issue too. Here is my mitigation, but it is definitely not an ideal fix: https://github.com/skjdghsdjgsdj/matrixportal-babybuddy/commit/43c54d13717310dbdfa641ed72af9d7b0b714fd3