Skip to content

Commit 5786532

Browse files
committed
Remove deprecated datetime.utcnow() in favour of datetime.now(tz=tzutc())
1 parent 5fdd617 commit 5786532

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

posthog/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def _enqueue(self, msg, disable_geoip):
342342

343343
timestamp = msg["timestamp"]
344344
if timestamp is None:
345-
timestamp = datetime.utcnow().replace(tzinfo=tzutc())
345+
timestamp = datetime.now(tz=tzutc())
346346

347347
require("timestamp", timestamp, datetime)
348348
require("context", msg["context"], dict)
@@ -463,7 +463,7 @@ def _load_feature_flags(self):
463463
)
464464
self.log.warning(e)
465465

466-
self._last_feature_flag_poll = datetime.utcnow().replace(tzinfo=tzutc())
466+
self._last_feature_flag_poll = datetime.now(tz=tzutc())
467467

468468
def load_feature_flags(self):
469469
if not self.personal_api_key:

posthog/request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def post(
3737
"""Post the `kwargs` to the API"""
3838
log = logging.getLogger("posthog")
3939
body = kwargs
40-
body["sentAt"] = datetime.utcnow().replace(tzinfo=tzutc()).isoformat()
40+
body["sentAt"] = datetime.now(tz=tzutc()).isoformat()
4141
url = remove_trailing_slash(host or DEFAULT_HOST) + path
4242
body["api_key"] = api_key
4343
data = json.dumps(body, cls=DatetimeSerializer)

0 commit comments

Comments
 (0)