Skip to content

Remove uses of datetime.utcnow #5489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Remove uses of datetime.utcnow #5489

wants to merge 2 commits into from

Conversation

quis
Copy link
Member

@quis quis commented Jun 2, 2025

datetime.utcnow is deprecated as of Python 3.12: https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow

The docs say:

Use datetime.now() with datetime.UTC instead.

There are a few cases where we pass serialised datetimes to the API. Because the API might be expecting datetimes in a particular format I’ve written a couple of helper methods to deal with this. In the future we could investigate whether the API really needs datetimes in those exact formats.

I’ve changed the tests as a separate commit so it’s easy to see that:

  • the changes to the app code pass the existing tests
  • the changes to the tests don’t break the app code

You can verify this by running git rebase origin/main -ix "make test"

quis added 2 commits June 2, 2025 09:46
`datetime.utcnow` is deprecated as of Python 3.12:
https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow

The docs say:
> Use `datetime.now()` with `datetime.UTC` instead.

There are a few cases where we pass serialised datetimes to the API.
Because the API might be expecting datetimes in a particular format I’ve
written a couple of helper methods to deal with this. In the future we
could investiagate whether the API really needs datetimes in those
specific formats.
`datetime.utcnow` is deprecated as of Python 3.12:
https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow

The docs say:
> Use `datetime.now()` with `datetime.UTC` instead.

Doing this as a separate commit so it’s easy to see that the app changes
pass the existing tests.
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.

1 participant