From 34faebfc83dd79ba5fdc54c9f36a9af0fd49b263 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 9 Dec 2024 11:11:16 -0600 Subject: [PATCH] support iso format with Z on end for timezone. --- adafruit_datetime.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/adafruit_datetime.py b/adafruit_datetime.py index ef57823..99e30a4 100755 --- a/adafruit_datetime.py +++ b/adafruit_datetime.py @@ -923,7 +923,7 @@ def __new__( microsecond: int = 0, tzinfo: Optional[tzinfo] = None, *, - fold: int = 0 + fold: int = 0, ) -> "time": _check_time_fields(hour, minute, second, microsecond, fold) _check_tzinfo_arg(tzinfo) @@ -994,6 +994,8 @@ def fromisoformat(cls, time_string: str) -> "time": Valid format is ``HH[:MM[:SS[.fff[fff]]]][+HH:MM[:SS[.ffffff]]]`` """ + if time_string[-1] == "Z": + time_string = f"{time_string[:-1]}+00:00" # Store the original string in an error message original_string = time_string match = _re.match(r"(.*)[\-\+]", time_string) @@ -1254,7 +1256,7 @@ def __new__( microsecond: int = 0, tzinfo: Optional[tzinfo] = None, *, - fold: int = 0 + fold: int = 0, ) -> "datetime": _check_date_fields(year, month, day) _check_time_fields(hour, minute, second, microsecond, fold) @@ -1599,7 +1601,7 @@ def replace( microsecond: Optional[str] = None, tzinfo: bool = True, *, - fold: Optional[int] = None + fold: Optional[int] = None, ) -> "datetime": """Return a datetime with the same attributes, except for those attributes given new values by