From b67c668937ae3a34a6c4d73ea9b4a36309abb899 Mon Sep 17 00:00:00 2001 From: The Metaist Date: Tue, 17 Sep 2024 23:33:21 -0400 Subject: [PATCH] fix: fromisoformat doesn't accept Z (closes #8) --- src/cosmofy/updater.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cosmofy/updater.py b/src/cosmofy/updater.py index f09663b..64a30f2 100755 --- a/src/cosmofy/updater.py +++ b/src/cosmofy/updater.py @@ -191,7 +191,7 @@ def update(self, **values: str) -> Receipt: """Update this receipt with several values.""" for name, value in values.items(): if name == "date": - self.date = datetime.fromisoformat(value) + self.date = datetime.fromisoformat(value.replace("Z", "+00:00")) else: setattr(self, name, value) return self @@ -211,7 +211,7 @@ def from_dict(data: Dict[str, str]) -> Receipt: _data = {**data} # copy to prevent modification schema = _data.pop("$schema") - date = datetime.fromisoformat(_data.pop("date")) + date = datetime.fromisoformat(_data.pop("date").replace("Z", "+00:00")) kind: RECEIPT_KIND = ( # mypy can't detect this properly "published" if _data.pop("kind") == "published" else "embedded" )