summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-04-10 13:00:00 +0200
committermathieui <mathieui@mathieui.net>2021-04-11 16:33:53 +0200
commit73767bc97a929eb37ae5380e9966a0c17a1dc4a5 (patch)
tree63f5de54d428f6dfe164d7957ee9500c50ac7677
parente49552e4449bc02daa2aa08738a29810dbcd07cb (diff)
downloadpoezio-73767bc97a929eb37ae5380e9966a0c17a1dc4a5.tar.gz
poezio-73767bc97a929eb37ae5380e9966a0c17a1dc4a5.tar.bz2
poezio-73767bc97a929eb37ae5380e9966a0c17a1dc4a5.tar.xz
poezio-73767bc97a929eb37ae5380e9966a0c17a1dc4a5.zip
fix: issue when converting local timezones
-rw-r--r--poezio/common.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/poezio/common.py b/poezio/common.py
index 69e41c83..f80555ac 100644
--- a/poezio/common.py
+++ b/poezio/common.py
@@ -498,11 +498,11 @@ def unique_prefix_of(a: str, b: str) -> str:
def to_utc(time_: datetime) -> datetime:
"""Convert a datetime-aware time zone into raw UTC"""
- tzone = datetime.now().astimezone().tzinfo
if time_.tzinfo is not None: # Convert to UTC
time_ = time_.astimezone(tz=timezone.utc)
- else: # Assume local tz, convert to URC
- time = time_.replace(tzinfo=tzone).astimezone(tz=timezone.utc)
+ else: # Assume local tz, convert to UTC
+ tzone = datetime.now().astimezone().tzinfo
+ time_ = time_.replace(tzinfo=tzone).astimezone(tz=timezone.utc)
# Return an offset-naive datetime
return time_.replace(tzinfo=None)