|
@@ -1,4 +1,4 @@
|
|
|
-# -*- coding: utf-8 -*-
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
'''
|
|
|
Sitemap
|
|
|
-------
|
|
@@ -14,6 +14,7 @@ import os.path
|
|
|
from datetime import datetime
|
|
|
from logging import warning, info
|
|
|
from codecs import open
|
|
|
+from pytz import timezone
|
|
|
|
|
|
from pelican import signals, contents
|
|
|
from pelican.utils import get_date
|
|
@@ -61,6 +62,11 @@ class SitemapGenerator(object):
|
|
|
self.now = datetime.now()
|
|
|
self.siteurl = settings.get('SITEURL')
|
|
|
|
|
|
+
|
|
|
+ self.default_timezone = settings.get('TIMEZONE', 'UTC')
|
|
|
+ self.timezone = getattr(self, 'timezone', self.default_timezone)
|
|
|
+ self.timezone = timezone(self.timezone)
|
|
|
+
|
|
|
self.format = 'xml'
|
|
|
|
|
|
self.changefreqs = {
|
|
@@ -166,11 +172,11 @@ class SitemapGenerator(object):
|
|
|
|
|
|
def set_url_wrappers_modification_date(self, wrappers):
|
|
|
for (wrapper, articles) in wrappers:
|
|
|
- lastmod = datetime.min
|
|
|
+ lastmod = datetime.min.replace(tzinfo=self.timezone)
|
|
|
for article in articles:
|
|
|
lastmod = max(lastmod, article.date)
|
|
|
try:
|
|
|
- modified = self.get_date_modified(article, datetime.min);
|
|
|
+ modified = self.get_date_modified(article, datetime.min.replace(tzinfo=self.timezone));
|
|
|
lastmod = max(lastmod, modified)
|
|
|
except ValueError:
|
|
|
# Supressed: user will be notified.
|