diff --git a/traits/util/event_tracer.py b/traits/util/event_tracer.py index 0769f315f..acb226c70 100644 --- a/traits/util/event_tracer.py +++ b/traits/util/event_tracer.py @@ -15,7 +15,7 @@ import os import threading from contextlib import contextmanager -from datetime import datetime +from datetime import datetime, timezone from traits import trait_notifiers @@ -228,7 +228,7 @@ def pre_tracer(self, obj, name, old, new, handler): """ indent = self.indent - time = datetime.utcnow().isoformat(" ") + time = datetime.now(timezone.utc).isoformat(" ") container = self.container container.record( ChangeMessageRecord( @@ -255,7 +255,7 @@ def post_tracer(self, obj, name, old, new, handler, exception=None): """ Record a string representation of the trait change return """ - time = datetime.utcnow().isoformat(" ") + time = datetime.now(timezone.utc).isoformat(" ") self.indent -= 1 indent = self.indent if exception: