Replace deprecated datetime.utcfromtimestamp and utcnow#521
Open
bysiber wants to merge 1 commit intoitamarst:masterfrom
Open
Replace deprecated datetime.utcfromtimestamp and utcnow#521bysiber wants to merge 1 commit intoitamarst:masterfrom
bysiber wants to merge 1 commit intoitamarst:masterfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #517.
datetime.utcfromtimestamp()anddatetime.utcnow()have been deprecated since Python 3.12 and are scheduled for removal.This replaces:
datetime.utcfromtimestamp()inprettyprint.pywithdatetime.fromtimestamp(ts, tz=timezone.utc). The+00:00suffix is stripped so the output format stays the same (ISO 8601 with trailingZ).datetime.utcnow()in a test expression withdatetime.now(), since the test only checks that subtracting two datetimes produces atimedeltainstance.