Skip to content

Commit

Permalink
Fix deprecation of "datetime.utcfromoffset()"
Browse files Browse the repository at this point in the history
Although it's not recommended, we still use a naive datetime for UTC
time (to calculate the local offset). I'm sure there's a more elegant
solution, but as this is code for old, untestable platforms, I'd
rather not radically change the implementation.
  • Loading branch information
Delgan committed Sep 11, 2023
1 parent f1e94ab commit 37a2db2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion loguru/_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ def aware_now():
seconds = local.tm_gmtoff
zone = local.tm_zone
except AttributeError:
offset = datetime_.fromtimestamp(timestamp) - datetime_.utcfromtimestamp(timestamp)
# Workaround for Python 3.5.
utc_naive = datetime_.fromtimestamp(timestamp, tz=timezone.utc).replace(tzinfo=None)
offset = datetime_.fromtimestamp(timestamp) - utc_naive
seconds = offset.total_seconds()
zone = strftime("%Z")

Expand Down

0 comments on commit 37a2db2

Please sign in to comment.