forked from github/pelican
parent
715c056cd4
commit
1d2bf8e96e
5 changed files with 33 additions and 23 deletions
|
|
@ -18,10 +18,12 @@ from operator import attrgetter
|
|||
|
||||
import dateutil.parser
|
||||
|
||||
try:
|
||||
import zoneinfo
|
||||
except ModuleNotFoundError:
|
||||
from backports import zoneinfo
|
||||
from markupsafe import Markup
|
||||
|
||||
import pytz
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -919,10 +921,11 @@ 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:
|
||||
tz = pytz.timezone(tz_name)
|
||||
d = tz.localize(d)
|
||||
return SafeDatetime(d.year, d.month, d.day, d.hour, d.minute, d.second,
|
||||
d.microsecond, d.tzinfo)
|
||||
timezone = zoneinfo.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
|
||||
)
|
||||
return d
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue