##// END OF EJS Templates
Properly parse feed timestamp
neko259 -
r1970:075e04c3 default
parent child Browse files
Show More
@@ -1,5 +1,6 b''
1 import feedparser
1 import feedparser
2 import logging
2 import logging
3 import calendar
3
4
4 from time import mktime
5 from time import mktime
5 from datetime import datetime
6 from datetime import datetime
@@ -51,7 +52,7 b' class ThreadSource(models.Model):'
51 items = sorted(feed.entries, key=lambda entry: entry.published_parsed)
52 items = sorted(feed.entries, key=lambda entry: entry.published_parsed)
52 for item in items:
53 for item in items:
53 title = item.title[:TITLE_MAX_LENGTH]
54 title = item.title[:TITLE_MAX_LENGTH]
54 timestamp = datetime.fromtimestamp(mktime(item.published_parsed), tz=utc)
55 timestamp = datetime.fromtimestamp(calendar.timegm(item.published_parsed), tz=utc)
55 if not timestamp:
56 if not timestamp:
56 logger.error('Invalid timestamp {} for {}'.format(item.published, title))
57 logger.error('Invalid timestamp {} for {}'.format(item.published, title))
57 else:
58 else:
General Comments 0
You need to be logged in to leave comments. Login now