Skip to content

Commit

Permalink
Merge branch 'mr/ramonat/avoid-deprecated-utcnow' into 'master'
Browse files Browse the repository at this point in the history
Use timezone-aware objects to represent datetimes in UTC

See merge request it/e3-core!73
  • Loading branch information
enzbang committed Dec 11, 2024
2 parents 7e5ce2b + c60f620 commit 12c2b59
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/e3/date.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import calendar
from datetime import datetime
from datetime import datetime, timezone
import time
from typing import overload

Expand All @@ -27,5 +27,5 @@ def timestamp_as_string(value: float | None) -> str | None:

def utc_timestamp() -> int:
"""Return the number of seconds since epoch UTC."""
d = datetime.utcnow()
d = datetime.now(tz=timezone.utc)
return calendar.timegm(d.utctimetuple())

0 comments on commit 12c2b59

Please sign in to comment.