1
0
Fork 0
forked from github/pelican

Replace pytz dependency in tests (#3165)

This commit is contained in:
Will Thong 2023-08-15 19:07:39 +01:00 committed by GitHub
commit 2eeff62fd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 16 deletions

View file

@ -19,9 +19,9 @@ from operator import attrgetter
import dateutil.parser
try:
import zoneinfo
from zoneinfo import ZoneInfo
except ModuleNotFoundError:
from backports import zoneinfo
from backports.zoneinfo import ZoneInfo
from markupsafe import Markup
@ -921,7 +921,7 @@ class FileSystemWatcher:
def set_date_tzinfo(d, tz_name=None):
"""Set the timezone for dates that don't have tzinfo"""
if tz_name and not d.tzinfo:
timezone = zoneinfo.ZoneInfo(tz_name)
timezone = ZoneInfo(tz_name)
d = d.replace(tzinfo=timezone)
return SafeDatetime(
d.year, d.month, d.day, d.hour, d.minute, d.second, d.microsecond, d.tzinfo