From 080f0238357436a680f194f57f7142e048ed6bd9 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 17 Nov 2024 17:20:05 +0100 Subject: [PATCH] correctly fix time_now --- src/utils/misc.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/utils/misc.py b/src/utils/misc.py index 29f9e21..b6e757f 100644 --- a/src/utils/misc.py +++ b/src/utils/misc.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import UTC, datetime from os import listdir, utime from os import path as os_path from os import remove as os_remove @@ -98,8 +98,12 @@ def exist_post(file_id: int) -> float | None: def time_now() -> float: - """get current time based on timezone""" - return datetime.now(timezone(session[Config._session_timezone])).timestamp() + """get current time based on timezone without being timezone aware""" + now = datetime.now(UTC).replace(tzinfo=None) + return ( + now.timestamp() + + timezone(session[Config._session_timezone]).utcoffset(now).total_seconds() + ) def create_post(file_id: int, content: str) -> bool: