From 3e6868f7cfa001adf2f1bf2cc9e29003c6a6904d Mon Sep 17 00:00:00 2001 From: "dries.k" Date: Wed, 9 Feb 2022 17:16:48 +0100 Subject: [PATCH] do not trash milliseconds --- gotify_tray/gotify/models.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gotify_tray/gotify/models.py b/gotify_tray/gotify/models.py index 2a25a40..4a98c3b 100644 --- a/gotify_tray/gotify/models.py +++ b/gotify_tray/gotify/models.py @@ -47,12 +47,15 @@ class GotifyMessageModel(AttributeDict): title: Optional[str] = None def __init__(self, d: dict, *args, **kwargs): + s = ( + d["date"].split(".")[0] # date + + "." + + d["date"].split(".")[1][:6] # ms + + "+" + + d["date"].split("+")[-1] # timezone + ) d.update( - { - "date": datetime.datetime.fromisoformat( - d["date"].split(".")[0] + ".000000+" + d["date"].split("+")[-1] - ).astimezone(local_timezone) - } + {"date": datetime.datetime.fromisoformat(s).astimezone(local_timezone)} ) super(GotifyMessageModel, self).__init__(d, *args, **kwargs)