Skip to content

Commit

Permalink
datetime.UTC is 3.11+ :(
Browse files Browse the repository at this point in the history
  • Loading branch information
Hook25 committed Jan 22, 2025
1 parent 042e0a3 commit 54fecd6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion checkbox-ng/checkbox_ng/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ def generate_resume_candidate_description(candidate):
last_job_id = candidate.metadata.running_job_name or "Unknown"
last_job_timestamp = candidate.metadata.last_job_start_time or None
if last_job_timestamp:
dt = datetime.datetime.fromtimestamp(last_job_timestamp, datetime.UTC)
dt = datetime.datetime.fromtimestamp(
last_job_timestamp, datetime.timezone.utc
)
last_job_start_time = dt.strftime("%Y-%m-%d %H:%M:%S")
else:
last_job_start_time = "Unknown"
Expand Down
2 changes: 1 addition & 1 deletion checkbox-ng/plainbox/impl/exporter/jinja2.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __init__(
self._system_id = system_id
# Generate a time-stamp if needed
self._timestamp = timestamp or datetime.datetime.now(
datetime.UTC
datetime.timezone.utc
).strftime("%Y-%m-%dT%H:%M:%S")
# Use current version unless told otherwise
self._client_version = client_version or get_version_string()
Expand Down
4 changes: 2 additions & 2 deletions checkbox-ng/plainbox/impl/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def on_begin(self, args, kwargs):
Begins tracking time (relative time entries)
"""
self.last_msg = datetime.datetime.now(datetime.UTC)
self.last_msg = datetime.datetime.now(datetime.timezone.utc)

def on_line(self, stream_name, line):
"""
Expand All @@ -72,7 +72,7 @@ def on_line(self, stream_name, line):
Maintains a timestamp of the last message so that approximate delay
between each piece of output can be recorded as well.
"""
now = datetime.datetime.now(datetime.UTC)
now = datetime.datetime.now(datetime.timezone.utc)
delay = now - self.last_msg
self.last_msg = now
record = IOLogRecord(delay.total_seconds(), stream_name, line)
Expand Down
4 changes: 3 additions & 1 deletion checkbox-ng/plainbox/impl/session/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ def create(cls, prefix="pbox-"):
WellKnownDirsHelper.populate_base()

isoformat = "%Y-%m-%dT%H.%M.%S"
timestamp = datetime.datetime.now(datetime.UTC).strftime(isoformat)
timestamp = datetime.datetime.now(datetime.timezone.utc).strftime(
isoformat
)
session_id = "{prefix}{timestamp}".format(
prefix=slugify(prefix), timestamp=timestamp
)
Expand Down

0 comments on commit 54fecd6

Please sign in to comment.