From 2dd7a57344c9169428d3c8865e753af5f2d5e7d0 Mon Sep 17 00:00:00 2001 From: Bo Date: Mon, 9 Oct 2023 16:04:22 -0400 Subject: [PATCH] Update timestamp handling (#314) Co-authored-by: DevilXD --- utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 1457309..91ca34e 100644 --- a/utils.py +++ b/utils.py @@ -109,7 +109,10 @@ def json_minify(data: JsonType | list[JsonType]) -> str: def timestamp(string: str) -> datetime: - return datetime.strptime(string, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=timezone.utc) + try: + return datetime.strptime(string, "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=timezone.utc) + except ValueError: + return datetime.strptime(string, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=timezone.utc) CHARS_ASCII = string.ascii_letters + string.digits