GMT Time in ATOM feeds

This commit is contained in:
Rémy HUBSCHER 2011-08-16 11:40:08 +02:00
commit acb65b77af
2 changed files with 11 additions and 2 deletions

View file

@ -2,6 +2,8 @@
import re
import os
import shutil
import time
import calendar
from datetime import datetime
from codecs import open as _open
from itertools import groupby
@ -222,3 +224,10 @@ def files_changed(path, extensions):
LAST_MTIME = mtime
return True
return False
def local_to_utc(t):
"Convert article time to UTC time for ATOM feeds"
secs = time.mktime(t)
gmtime = list(time.gmtime(secs))
gmtime[8] = 1
return datetime.fromtimestamp(time.mktime(gmtime))

View file

@ -7,7 +7,7 @@ from functools import partial
import locale
from feedgenerator import Atom1Feed, Rss201rev2Feed
from pelican.utils import get_relative_path
from pelican.utils import get_relative_path, local_to_utc
from pelican.paginator import Paginator
from pelican.log import *
@ -37,7 +37,7 @@ class Writer(object):
description=item.content,
categories=item.tags if hasattr(item, 'tags') else None,
author_name=getattr(item, 'author', 'John Doe'),
pubdate=item.date)
pubdate=local_to_utc(item.date.timetuple()))
def write_feed(self, elements, context, filename=None, feed_type='atom'):
"""Generate a feed with the list of articles provided