diff --git a/segment/analytics/client.py b/segment/analytics/client.py index 1d4e35d..0f8015c 100644 --- a/segment/analytics/client.py +++ b/segment/analytics/client.py @@ -267,7 +267,7 @@ def _enqueue(self, msg): """Push a new `msg` onto the queue, return `(success, msg)`""" timestamp = msg['timestamp'] if timestamp is None: - timestamp = datetime.utcnow().replace(tzinfo=tzutc()) + timestamp = datetime.now(tz=tzutc()) message_id = msg.get('messageId') if message_id is None: message_id = uuid4() diff --git a/segment/analytics/request.py b/segment/analytics/request.py index 273247c..1f5a56e 100644 --- a/segment/analytics/request.py +++ b/segment/analytics/request.py @@ -18,7 +18,7 @@ def post(write_key, host=None, gzip=False, timeout=15, proxies=None, oauth_manag log = logging.getLogger('segment') body = kwargs if not "sentAt" in body.keys(): - body["sentAt"] = datetime.utcnow().replace(tzinfo=tzutc()).isoformat() + body["sentAt"] = datetime.now(tz=tzutc()).isoformat() body["writeKey"] = write_key url = remove_trailing_slash(host or 'https://api.segment.io') + '/v1/batch' auth = None