Skip to content

Commit 243fd34

Browse files
authored
Merge pull request jupyterhub#1908 from agoose77/agoose77/fix-deprecation-utcnow
fix: handle deprecation of `datetime.utcnow()`
2 parents 65f807c + 1fdc709 commit 243fd34

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

binderhub/events.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
Emit structured, discrete events when various actions happen.
33
"""
44

5+
import datetime
56
import json
67
import logging
7-
from datetime import datetime
88

99
import jsonschema
1010
from jupyterhub.traitlets import Callable
@@ -98,8 +98,9 @@ def emit(self, schema_name, version, event):
9898
schema = self.schemas[(schema_name, version)]
9999
jsonschema.validate(event, schema)
100100

101+
now_utc = datetime.datetime.now(tz=datetime.timezone.utc)
101102
capsule = {
102-
"timestamp": datetime.utcnow().isoformat() + "Z",
103+
"timestamp": now_utc.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
103104
"schema": schema_name,
104105
"version": version,
105106
}

0 commit comments

Comments
 (0)