Skip to content

Replace deprecated datetime.utcnow() with timezone-aware datetime#26

Open
sklart wants to merge 2 commits into
itkach:masterfrom
sklart:master
Open

Replace deprecated datetime.utcnow() with timezone-aware datetime#26
sklart wants to merge 2 commits into
itkach:masterfrom
sklart:master

Conversation

@sklart

@sklart sklart commented Nov 5, 2025

Copy link
Copy Markdown
Contributor
  • Updated all occurrences of datetime.utcnow() to datetime.now(timezone.utc) to comply with modern Python standards and avoid DeprecationWarning.
    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). session_doc["updated_at"] = datetime.utcnow().isoformat()
  • Added timezone to datetime imports where missing.
  • Ensures created_at and updated_at fields are now timezone-aware UTC datetimes.
  • Maintains compatibility with Python >=3.2.

- Updated all occurrences of datetime.utcnow() to datetime.now(timezone.utc) to comply with modern Python standards and avoid DeprecationWarning.
'''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). session_doc["updated_at"] = datetime.utcnow().isoformat()'''
- Added `timezone` to datetime imports where missing.
- Ensures created_at and updated_at fields are now timezone-aware UTC datetimes.
- Maintains compatibility with Python >=3.2.
- Updated all occurrences of datetime.utcnow() to datetime.now(timezone.utc) to comply with modern Python standards and avoid DeprecationWarning.
`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). session_doc["updated_at"] = datetime.utcnow().isoformat()`
- Added `timezone` to datetime imports where missing.
- Ensures created_at and updated_at fields are now timezone-aware UTC datetimes.
- Maintains compatibility with Python >=3.2.
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