forked from rc/aircox
!112 Co-authored-by: bkfox <thomas bkfox net> Reviewed-on: rc/aircox#113
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import calendar
|
||||
import zoneinfo
|
||||
|
||||
import pytz
|
||||
from django.db import models
|
||||
from django.utils import timezone as tz
|
||||
from django.utils.functional import cached_property
|
||||
@ -49,9 +49,9 @@ class Schedule(Rerun):
|
||||
)
|
||||
timezone = models.CharField(
|
||||
_("timezone"),
|
||||
default=lambda: tz.get_current_timezone().zone,
|
||||
default=lambda: tz.get_current_timezone().key,
|
||||
max_length=100,
|
||||
choices=[(x, x) for x in pytz.all_timezones],
|
||||
choices=[(x, x) for x in zoneinfo.available_timezones()],
|
||||
help_text=_("timezone used for the date"),
|
||||
)
|
||||
duration = models.TimeField(
|
||||
@ -82,9 +82,7 @@ class Schedule(Rerun):
|
||||
@cached_property
|
||||
def tz(self):
|
||||
"""Pytz timezone of the schedule."""
|
||||
import pytz
|
||||
|
||||
return pytz.timezone(self.timezone)
|
||||
return zoneinfo.ZoneInfo(self.timezone)
|
||||
|
||||
@cached_property
|
||||
def start(self):
|
||||
@ -110,7 +108,7 @@ class Schedule(Rerun):
|
||||
"""Return a datetime set to schedule's time for the provided date,
|
||||
handling timezone (based on schedule's timezone)."""
|
||||
date = tz.datetime.combine(date, self.time)
|
||||
return self.tz.normalize(self.tz.localize(date))
|
||||
return date.replace(tzinfo=self.tz)
|
||||
|
||||
def dates_of_month(self, date):
|
||||
"""Return normalized diffusion dates of provided date's month."""
|
||||
|
Reference in New Issue
Block a user