Skip to content

Replace deprecated datetime.utcfromtimestamp and utcnow#521

Open
bysiber wants to merge 1 commit intoitamarst:masterfrom
bysiber:fix-deprecated-utcfromtimestamp
Open

Replace deprecated datetime.utcfromtimestamp and utcnow#521
bysiber wants to merge 1 commit intoitamarst:masterfrom
bysiber:fix-deprecated-utcfromtimestamp

Conversation

@bysiber
Copy link

@bysiber bysiber commented Feb 21, 2026

Fixes #517.

datetime.utcfromtimestamp() and datetime.utcnow() have been deprecated since Python 3.12 and are scheduled for removal.

This replaces:

  • datetime.utcfromtimestamp() in prettyprint.py with datetime.fromtimestamp(ts, tz=timezone.utc). The +00:00 suffix is stripped so the output format stays the same (ISO 8601 with trailing Z).
  • datetime.utcnow() in a test expression with datetime.now(), since the test only checks that subtracting two datetimes produces a timedelta instance.

datetime.utcfromtimestamp() and datetime.utcnow() are deprecated
since Python 3.12 and scheduled for removal. This replaces:

- utcfromtimestamp() in prettyprint.py with
  datetime.fromtimestamp(ts, tz=timezone.utc), stripping the
  +00:00 offset so the output stays as before (ISO format + Z)

- utcnow() in a test expression with datetime.now(), since the
  test only checks that the subtraction produces a timedelta

Fixes itamarst#517
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deprecated datetime

1 participant