mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
parent
715c056cd4
commit
1d2bf8e96e
5 changed files with 33 additions and 23 deletions
|
|
@ -4,10 +4,15 @@ import locale
|
|||
import logging
|
||||
import os
|
||||
import re
|
||||
from datetime import timezone
|
||||
from html import unescape
|
||||
from urllib.parse import unquote, urljoin, urlparse, urlunparse
|
||||
|
||||
import pytz
|
||||
try:
|
||||
import zoneinfo
|
||||
except ModuleNotFoundError:
|
||||
from backports import zoneinfo
|
||||
|
||||
|
||||
from pelican.plugins import signals
|
||||
from pelican.settings import DEFAULT_CONFIG
|
||||
|
|
@ -120,9 +125,9 @@ class Content:
|
|||
self.date_format = self.date_format[1]
|
||||
|
||||
# manage timezone
|
||||
default_timezone = settings.get('TIMEZONE', 'UTC')
|
||||
timezone = getattr(self, 'timezone', default_timezone)
|
||||
self.timezone = pytz.timezone(timezone)
|
||||
default_timezone = settings.get("TIMEZONE", "UTC")
|
||||
timezone = getattr(self, "timezone", default_timezone)
|
||||
self.timezone = zoneinfo.ZoneInfo(timezone)
|
||||
|
||||
if hasattr(self, 'date'):
|
||||
self.date = set_date_tzinfo(self.date, timezone)
|
||||
|
|
@ -525,7 +530,7 @@ class Article(Content):
|
|||
if self.date.tzinfo is None:
|
||||
now = datetime.datetime.now()
|
||||
else:
|
||||
now = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)
|
||||
now = datetime.datetime.utcnow().replace(tzinfo=timezone.utc)
|
||||
if self.date > now:
|
||||
self.status = 'draft'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue