chore: use settings.TIME_ZONE as default for date_today()

This commit is contained in:
Jennifer Richards 2022-10-17 17:36:47 -03:00
parent da70acfdff
commit bf6e0af2c9
No known key found for this signature in database
GPG key ID: 26801E4DC0928410

View file

@ -3,6 +3,7 @@ import datetime
from typing import Union
from zoneinfo import ZoneInfo
from django.conf import settings
from django.utils import timezone
@ -60,8 +61,11 @@ def datetime_today(tz=None):
def date_today(tz=None):
"""Get the date corresponding to the current moment
By default, uses settings.TIME_ZONE
Note that Dates are not themselves timezone aware.
"""
if tz is None:
tz = settings.TIME_ZONE
return timezone.now().astimezone(_tzinfo(tz)).date()