mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
fix up the datetime comparison error caused by timezone.
"can't compare offset-naive and offset-aware datetimes".
This commit is contained in:
parent
30b8a2069e
commit
4654a4efe4
1 changed files with 7 additions and 2 deletions
|
|
@ -11,6 +11,7 @@ import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import pytz
|
||||||
|
|
||||||
from pelican import signals
|
from pelican import signals
|
||||||
from pelican.settings import DEFAULT_CONFIG
|
from pelican.settings import DEFAULT_CONFIG
|
||||||
|
|
@ -132,8 +133,12 @@ class Content(object):
|
||||||
# manage status
|
# manage status
|
||||||
if not hasattr(self, 'status'):
|
if not hasattr(self, 'status'):
|
||||||
self.status = settings['DEFAULT_STATUS']
|
self.status = settings['DEFAULT_STATUS']
|
||||||
if not settings['WITH_FUTURE_DATES']:
|
if not settings['WITH_FUTURE_DATES'] and hasattr(self, 'date'):
|
||||||
if hasattr(self, 'date') and self.date > SafeDatetime.now():
|
if self.date.tzinfo is None:
|
||||||
|
now = SafeDatetime.now()
|
||||||
|
else:
|
||||||
|
now = SafeDatetime.utcnow().replace(tzinfo=pytz.utc)
|
||||||
|
if self.date > now:
|
||||||
self.status = 'draft'
|
self.status = 'draft'
|
||||||
|
|
||||||
# store the summary metadata if it is set
|
# store the summary metadata if it is set
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue