-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix future deprecate warning of django.utils.timezone.utc
- Loading branch information
1 parent
81f487f
commit 5d18c03
Showing
3 changed files
with
4 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
"""Utility functions to manage timezone code.""" | ||
|
||
from datetime import datetime | ||
from datetime import datetime, timezone | ||
|
||
from django.conf import settings | ||
from django.utils.timezone import utc | ||
|
||
|
||
def tz_aware(value: datetime) -> datetime: | ||
"""Return an UTC-aware datetime in case of USE_TZ=True.""" | ||
if settings.USE_TZ: | ||
value = value.replace(tzinfo=utc) | ||
value = value.replace(tzinfo=timezone.utc) | ||
|
||
return value |
This file contains 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