Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2022-10-09 15:58:09 +0300
committerPhilipp Hörist <philipp@hoerist.com>2022-10-09 15:58:09 +0300
commitdaabc9105ae684214894030d674edf9b11173c7f (patch)
treeeeffa5e67f0943387b1bb114e1d53c95736be7c4 /gajim/common/dbus
parentf12cf65e8c44105b3689d5519583475142276a18 (diff)
refactor: Remove usage of utc* datetime methods
datetime.utcnow() datetime.utcfromtimestamp() These methods are discouraged according to pythons documentation
Diffstat (limited to 'gajim/common/dbus')
-rw-r--r--gajim/common/dbus/location.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/gajim/common/dbus/location.py b/gajim/common/dbus/location.py
index dbb645aed..58d78a0e4 100644
--- a/gajim/common/dbus/location.py
+++ b/gajim/common/dbus/location.py
@@ -21,6 +21,7 @@ from typing import Optional
import logging
from datetime import datetime
+from datetime import timezone
from gi.repository import Gio
from gi.repository import GLib
@@ -76,7 +77,7 @@ class LocationListener:
# update data with info we just received
self._data = {'lat': lat, 'lon': lon, 'alt': alt, 'accuracy': acc}
- self._data['timestamp'] = self._timestamp_to_utc(timestamp)
+ self._data['timestamp'] = self._timestamp_to_string(timestamp)
self._send_location()
def _on_client_update(self,
@@ -132,6 +133,6 @@ class LocationListener:
self._emit(info)
@staticmethod
- def _timestamp_to_utc(timestamp: float) -> str:
- time = datetime.utcfromtimestamp(timestamp)
- return time.strftime('%Y-%m-%dT%H:%MZ')
+ def _timestamp_to_string(timestamp: float) -> str:
+ utc_datetime = datetime.fromtimestamp(timestamp, timezone.utc)
+ return utc_datetime.strftime('%Y-%m-%dT%H:%MZ')