Skip to content

Commit 7583887

Browse files
authored
Use now(tz=utc) instead of deprecated utcnow (#470)
1 parent 6c0cce7 commit 7583887

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

segment/analytics/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def _enqueue(self, msg):
267267
"""Push a new `msg` onto the queue, return `(success, msg)`"""
268268
timestamp = msg['timestamp']
269269
if timestamp is None:
270-
timestamp = datetime.utcnow().replace(tzinfo=tzutc())
270+
timestamp = datetime.now(tz=tzutc())
271271
message_id = msg.get('messageId')
272272
if message_id is None:
273273
message_id = uuid4()

segment/analytics/request.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def post(write_key, host=None, gzip=False, timeout=15, proxies=None, oauth_manag
1818
log = logging.getLogger('segment')
1919
body = kwargs
2020
if not "sentAt" in body.keys():
21-
body["sentAt"] = datetime.utcnow().replace(tzinfo=tzutc()).isoformat()
21+
body["sentAt"] = datetime.now(tz=tzutc()).isoformat()
2222
body["writeKey"] = write_key
2323
url = remove_trailing_slash(host or 'https://api.segment.io') + '/v1/batch'
2424
auth = None

0 commit comments

Comments
 (0)