Skip to content

Python 3.12 deprecated usage of datetime.utcnow() #88

Closed
@igoras1993

Description

@igoras1993

Describe the bug
Python 3.12 deprecated usage of datetime.utcnow():

datetime: datetime.datetime’s utcnow() and utcfromtimestamp() are deprecated and will be removed in a future version. Instead, use timezone-aware objects to represent datetimes in UTC: respectively, call now() and fromtimestamp() with the tz parameter set to datetime.UTC. (Contributed by Paul Ganssle in gh-103857.)

It may be a good idea to use tz-aware datetimes now.

To Reproduce
E.g. run AsyncFirebaseClient.build_apns_config(...)

.venv/lib/python3.12/site-packages/async_firebase/client.py:232: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    "apns-expiration": str(int(datetime.utcnow().timestamp()) + ttl),

Expected behavior
No warnings are logged.

Desktop:

  • OS: Ubuntu 22
  • Browser Not relevant
  • Package Version: 3.8.0

Smartphone:

  • Not relevant

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions