Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
daabc910
by Philipp Hörist at 2022-10-09T14:58:09+02:00
3 changed files:
Changes:
| ... | ... | @@ -21,6 +21,7 @@ |
| 21 | 21 | |
| 22 | 22 | import logging
|
| 23 | 23 | from datetime import datetime
|
| 24 | +from datetime import timezone
|
|
| 24 | 25 | |
| 25 | 26 | from gi.repository import Gio
|
| 26 | 27 | from gi.repository import GLib
|
| ... | ... | @@ -76,7 +77,7 @@ def _on_location_update(self, simple: Geoclue.Simple, *args: Any) -> None: |
| 76 | 77 | |
| 77 | 78 | # update data with info we just received
|
| 78 | 79 | self._data = {'lat': lat, 'lon': lon, 'alt': alt, 'accuracy': acc}
|
| 79 | - self._data['timestamp'] = self._timestamp_to_utc(timestamp)
|
|
| 80 | + self._data['timestamp'] = self._timestamp_to_string(timestamp)
|
|
| 80 | 81 | self._send_location()
|
| 81 | 82 | |
| 82 | 83 | def _on_client_update(self,
|
| ... | ... | @@ -132,6 +133,6 @@ def _send_location(self) -> None: |
| 132 | 133 | self._emit(info)
|
| 133 | 134 | |
| 134 | 135 | @staticmethod
|
| 135 | - def _timestamp_to_utc(timestamp: float) -> str:
|
|
| 136 | - time = datetime.utcfromtimestamp(timestamp)
|
|
| 137 | - return time.strftime('%Y-%m-%dT%H:%MZ') |
|
| 136 | + def _timestamp_to_string(timestamp: float) -> str:
|
|
| 137 | + utc_datetime = datetime.fromtimestamp(timestamp, timezone.utc)
|
|
| 138 | + return utc_datetime.strftime('%Y-%m-%dT%H:%MZ') |
| ... | ... | @@ -28,6 +28,7 @@ |
| 28 | 28 | from enum import IntEnum
|
| 29 | 29 | from enum import unique
|
| 30 | 30 | from datetime import datetime
|
| 31 | +from datetime import timezone
|
|
| 31 | 32 | |
| 32 | 33 | from gi.repository import Gtk
|
| 33 | 34 | from gi.repository import Gdk
|
| ... | ... | @@ -710,7 +711,7 @@ def get_iter_by_sid(self, typ, sid): |
| 710 | 711 | @staticmethod
|
| 711 | 712 | def __convert_date(epoch: float) -> str:
|
| 712 | 713 | # Converts date-time from seconds from epoch to iso 8601
|
| 713 | - dt = datetime.utcfromtimestamp(epoch)
|
|
| 714 | + dt = datetime.fromtimestamp(epoch, timezone.utc)
|
|
| 714 | 715 | return dt.isoformat() + 'Z'
|
| 715 | 716 | |
| 716 | 717 | def get_send_file_props(self,
|
| ... | ... | @@ -20,6 +20,7 @@ |
| 20 | 20 | import logging
|
| 21 | 21 | from datetime import datetime
|
| 22 | 22 | from datetime import timedelta
|
| 23 | +from datetime import timezone
|
|
| 23 | 24 | |
| 24 | 25 | from gi.repository import Gtk
|
| 25 | 26 | from gi.repository import GLib
|
| ... | ... | @@ -55,7 +56,7 @@ def __init__(self, account: str) -> None: |
| 55 | 56 | self._client = app.get_client(account)
|
| 56 | 57 | |
| 57 | 58 | self._timedelta: Optional[timedelta] = None
|
| 58 | - self._now = datetime.utcnow()
|
|
| 59 | + self._now = datetime.now(timezone.utc)
|
|
| 59 | 60 | self._query_id: Optional[str] = None
|
| 60 | 61 | self._start: Optional[datetime] = None
|
| 61 | 62 | self._end: Optional[datetime] = None
|
| ... | ... | @@ -69,9 +70,10 @@ def __init__(self, account: str) -> None: |
| 69 | 70 | if mam_start == ArchiveState.NEVER:
|
| 70 | 71 | self._current_start = self._now
|
| 71 | 72 | elif mam_start == ArchiveState.ALL:
|
| 72 | - self._current_start = datetime.utcfromtimestamp(0)
|
|
| 73 | + self._current_start = datetime.fromtimestamp(0, timezone.utc)
|
|
| 73 | 74 | else:
|
| 74 | - self._current_start = datetime.fromtimestamp(mam_start)
|
|
| 75 | + self._current_start = datetime.fromtimestamp(mam_start,
|
|
| 76 | + timezone.utc)
|
|
| 75 | 77 | |
| 76 | 78 | self.add_button('synchronize', _('Synchronize'), 'suggested-action')
|
| 77 | 79 | self.add_button('close', _('Close'))
|