Skip to content

Commit

Permalink
Remove deprecated datetime.utcnow() in favour of datetime.now(tz=tzut…
Browse files Browse the repository at this point in the history
…c())
  • Loading branch information
silvanocerza committed May 29, 2024
1 parent 5fdd617 commit 5786532
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions posthog/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def _enqueue(self, msg, disable_geoip):

timestamp = msg["timestamp"]
if timestamp is None:
timestamp = datetime.utcnow().replace(tzinfo=tzutc())
timestamp = datetime.now(tz=tzutc())

require("timestamp", timestamp, datetime)
require("context", msg["context"], dict)
Expand Down Expand Up @@ -463,7 +463,7 @@ def _load_feature_flags(self):
)
self.log.warning(e)

self._last_feature_flag_poll = datetime.utcnow().replace(tzinfo=tzutc())
self._last_feature_flag_poll = datetime.now(tz=tzutc())

def load_feature_flags(self):
if not self.personal_api_key:
Expand Down
2 changes: 1 addition & 1 deletion posthog/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def post(
"""Post the `kwargs` to the API"""
log = logging.getLogger("posthog")
body = kwargs
body["sentAt"] = datetime.utcnow().replace(tzinfo=tzutc()).isoformat()
body["sentAt"] = datetime.now(tz=tzutc()).isoformat()
url = remove_trailing_slash(host or DEFAULT_HOST) + path
body["api_key"] = api_key
data = json.dumps(body, cls=DatetimeSerializer)
Expand Down

0 comments on commit 5786532

Please sign in to comment.