Replace deprecated django.utils.timezone.utc
It was deprecated in django 4.1[1] and was removed in django 5.0[2]. [1]59ab3fd0e9
[2]d6816bff73
Closes-Bug: #2092445 Change-Id: Ie7aafab66560bbb4e265b69c79c83d187e455a53
This commit is contained in:
parent
e1fde47a0c
commit
2dc9b5475c
@ -39,7 +39,8 @@ class ParseDateNode(template.Node):
|
||||
try:
|
||||
parsed = datetime.strptime(datestring, format)
|
||||
if not timezone.is_aware(parsed):
|
||||
parsed = timezone.make_aware(parsed, timezone.utc)
|
||||
parsed = timezone.make_aware(
|
||||
parsed, datetime.timezone.utc)
|
||||
return parsed
|
||||
except Exception:
|
||||
pass
|
||||
|
@ -95,7 +95,7 @@ def is_token_valid(token, margin=None):
|
||||
expiration = expiration - datetime.timedelta(seconds=margin)
|
||||
if settings.USE_TZ and timezone.is_naive(expiration):
|
||||
# Presumes that the Keystone is using UTC.
|
||||
expiration = timezone.make_aware(expiration, timezone.utc)
|
||||
expiration = timezone.make_aware(expiration, datetime.timezone.utc)
|
||||
return expiration > timezone.now()
|
||||
|
||||
|
||||
|
@ -47,12 +47,12 @@ class BaseUsage(object):
|
||||
@staticmethod
|
||||
def get_start(year, month, day):
|
||||
start = datetime.datetime(year, month, day, 0, 0, 0)
|
||||
return timezone.make_aware(start, timezone.utc)
|
||||
return timezone.make_aware(start, datetime.timezone.utc)
|
||||
|
||||
@staticmethod
|
||||
def get_end(year, month, day):
|
||||
end = datetime.datetime(year, month, day, 23, 59, 59)
|
||||
return timezone.make_aware(end, timezone.utc)
|
||||
return timezone.make_aware(end, datetime.timezone.utc)
|
||||
|
||||
def get_instances(self):
|
||||
instance_list = []
|
||||
@ -118,8 +118,8 @@ class BaseUsage(object):
|
||||
if start <= end and start <= self.today:
|
||||
# The API can't handle timezone aware datetime, so convert back
|
||||
# to naive UTC just for this last step.
|
||||
start = timezone.make_naive(start, timezone.utc)
|
||||
end = timezone.make_naive(end, timezone.utc)
|
||||
start = timezone.make_naive(start, datetime.timezone.utc)
|
||||
end = timezone.make_naive(end, datetime.timezone.utc)
|
||||
try:
|
||||
self.usage_list = self.get_usage_list(start, end)
|
||||
except Exception:
|
||||
|
Loading…
x
Reference in New Issue
Block a user