Use zoneinfo instead of tz

Co-Authored-By: Trenton Holmes <797416+stumpylog@users.noreply.github.com>
This commit is contained in:
Michael Shamoon 2022-05-16 21:39:10 -07:00
parent 6fbe4404f5
commit 88b7f8ac1e

View File

@ -2,8 +2,11 @@ import datetime
import math import math
import re import re
try:
import zoneinfo
except ImportError:
import backports.zoneinfo as zoneinfo
import magic import magic
from dateutil import tz
from django.conf import settings from django.conf import settings
from django.utils.text import slugify from django.utils.text import slugify
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
@ -224,7 +227,7 @@ class DocumentSerializer(DynamicFieldsModelSerializer):
if "created_date" in validated_data and "created" not in validated_data: if "created_date" in validated_data and "created" not in validated_data:
new_datetime = datetime.datetime.combine( new_datetime = datetime.datetime.combine(
validated_data.get("created_date"), validated_data.get("created_date"),
datetime.time(0, 0, 0, 0, tz.gettz(settings.TIME_ZONE)), datetime.time(0, 0, 0, 0, zoneinfo.ZoneInfo(settings.TIME_ZONE)),
) )
instance.created = new_datetime instance.created = new_datetime
instance.save() instance.save()