Skip to content

Commit

Permalink
Use datetime.UTC instead of datetime.timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Nov 21, 2023
1 parent 7faf67b commit 8993f90
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/cli/cliLog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8993f90

Please sign in to comment.