From 3e2f8c51d24c8e94ee2066b50ea4c70dbf094a11 Mon Sep 17 00:00:00 2001 From: Martin Wagner Date: Fri, 27 May 2022 22:52:02 +0200 Subject: [PATCH] use GLib.DateTime to parse time --- src/mpdevil.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mpdevil.py b/src/mpdevil.py index 6debe7a..ec3c7ca 100755 --- a/src/mpdevil.py +++ b/src/mpdevil.py @@ -516,8 +516,7 @@ class LastModified(): self._date=date def __str__(self): - time=datetime.datetime.strptime(self._date, "%Y-%m-%dT%H:%M:%SZ").replace(tzinfo=datetime.timezone.utc) - return time.astimezone(tz=None).strftime("%a %d %B %Y, %H∶%M") + return GLib.DateTime.new_from_iso8601(self._date).to_local().format("%a %d %B %Y, %H∶%M") def raw(self): return self._date @@ -1274,7 +1273,7 @@ class ServerStats(Gtk.Dialog): stats["protocol"]=str(client.mpd_version) for key in ("uptime","playtime","db_playtime"): stats[key]=str(Duration(stats[key])) - stats["db_update"]=datetime.datetime.fromtimestamp(int(stats["db_update"])).strftime("%a %d %B %Y, %H∶%M") + stats["db_update"]=GLib.DateTime.new_from_unix_local(int(stats["db_update"])).format("%a %d %B %Y, %H∶%M") for i, key in enumerate(("protocol","uptime","playtime","db_update","db_playtime","artists","albums","songs")): grid.attach(Gtk.Label(label=display_str[key], use_markup=True, xalign=1), 0, i, 1, 1)