From 8993f909623db47fcbbc45af205ecc19ebce24c9 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Tue, 21 Nov 2023 13:10:05 -0700 Subject: [PATCH] Use datetime.UTC instead of datetime.timezone --- python/lsst/daf/butler/cli/cliLog.py | 2 +- python/lsst/daf/butler/logging.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/lsst/daf/butler/cli/cliLog.py b/python/lsst/daf/butler/cli/cliLog.py index 45ac6e4b46..720c19acbe 100644 --- a/python/lsst/daf/butler/cli/cliLog.py +++ b/python/lsst/daf/butler/cli/cliLog.py @@ -56,7 +56,7 @@ class PrecisionLogFormatter(logging.Formatter): def formatTime(self, record: logging.LogRecord, datefmt: str | None = None) -> str: """Format the time as an aware datetime.""" - ct: datetime.datetime = self.converter(record.created, tz=datetime.timezone.utc) # type: ignore + ct: datetime.datetime = self.converter(record.created, tz=datetime.UTC) # type: ignore if self.use_local: ct = ct.astimezone() if datefmt: diff --git a/python/lsst/daf/butler/logging.py b/python/lsst/daf/butler/logging.py index 8c6b97bc5a..3a5ea11a6a 100644 --- a/python/lsst/daf/butler/logging.py +++ b/python/lsst/daf/butler/logging.py @@ -236,7 +236,7 @@ def from_record(cls, record: LogRecord) -> "ButlerLogRecord": # Always use UTC because in distributed systems we can't be sure # what timezone localtime is and it's easier to compare logs if # every system is using the same time. - record_dict["asctime"] = datetime.datetime.fromtimestamp(record.created, tz=datetime.timezone.utc) + record_dict["asctime"] = datetime.datetime.fromtimestamp(record.created, tz=datetime.UTC) # Sometimes exception information is included so must be # extracted.