Daniel Brötzmann pushed to branch master at gajim / gajim


Commits:
33d9f189 by wurstsalat at 2024-08-04T23:53:04+02:00
refactor: Move some datetime utils and improve imports

- - - - -


3 changed files:

- gajim/common/helpers.py
- gajim/common/util/datetime.py
- gajim/gtk/conversation/view.py


Changes:

=====================================
gajim/common/helpers.py
=====================================
@@ -1438,13 +1438,6 @@ def get_random_muc_localpart() -> str:
     return result
 
 
-def get_start_of_day(date_time: datetime) -> datetime:
-    return date_time.replace(hour=0,
-                             minute=0,
-                             second=0,
-                             microsecond=0)
-
-
 def make_path_from_jid(base_path: Path, jid: JID) -> Path:
     assert jid.domain is not None
     domain = jid.domain[:50]


=====================================
gajim/common/util/datetime.py
=====================================
@@ -4,17 +4,20 @@
 
 from __future__ import annotations
 
-from datetime import datetime
-from datetime import timezone
+import datetime as dt
 
-FIRST_UTC_DATETIME = datetime(1970, 1, 1, tzinfo=timezone.utc)
+FIRST_UTC_DATETIME = dt.datetime(1970, 1, 1, tzinfo=dt.timezone.utc)
 FIRST_LOCAL_DATETIME = FIRST_UTC_DATETIME.astimezone()
 
 
-def convert_epoch_to_local_datetime(utc_timestamp: float) -> datetime:
-    utc = datetime.fromtimestamp(utc_timestamp, tz=timezone.utc)
+def convert_epoch_to_local_datetime(utc_timestamp: float) -> dt.datetime:
+    utc = dt.datetime.fromtimestamp(utc_timestamp, tz=dt.timezone.utc)
     return utc.astimezone()
 
 
-def utc_now() -> datetime:
-    return datetime.now(timezone.utc)
+def utc_now() -> dt.datetime:
+    return dt.datetime.now(dt.timezone.utc)
+
+
+def get_start_of_day(datetime: dt.datetime) -> dt.datetime:
+    return datetime.replace(hour=0, minute=0, second=0, microsecond=0)


=====================================
gajim/gtk/conversation/view.py
=====================================
@@ -26,7 +26,6 @@
 from gajim.common import events
 from gajim.common import types
 from gajim.common.const import Direction
-from gajim.common.helpers import get_start_of_day
 from gajim.common.helpers import to_user_string
 from gajim.common.modules.contacts import BareContact
 from gajim.common.modules.contacts import GroupchatContact
@@ -34,6 +33,7 @@
 from gajim.common.storage.archive.const import ChatDirection
 from gajim.common.storage.archive.models import Message
 from gajim.common.types import ChatContactT
+from gajim.common.util.datetime import get_start_of_day
 
 from gajim.gtk.conversation.rows.base import BaseRow
 from gajim.gtk.conversation.rows.call import CallRow



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/33d9f18961335055f10d4602ce8eb488192b216b

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/33d9f18961335055f10d4602ce8eb488192b216b
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- commits@gajim.org
To unsubscribe send an email to commits-le...@gajim.org

Reply via email to