• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

news4 - RSS aggrigation system


Commit MetaInfo

Revision78b336a87914f4d54834ee9d80eac895b0121b22 (tree)
Time2012-10-02 05:50:51
Authorhylom <hylom@hylo...>
Commiterhylom

Log Message

fix timestamp-compareing problem

Change Summary

Incremental Difference

--- a/fetcher.py
+++ b/fetcher.py
@@ -4,6 +4,7 @@
44 import re
55
66 import feedparser
7+import dateutil.parser
78 from config import config as config, target_rss as target_rss
89
910 class FeedFetcher(object):
@@ -21,10 +22,12 @@ class FeedFetcher(object):
2122 'title': e.title,
2223 'link': e.link,
2324 'body': e.description,
24- 'date': e.updated,
25+ 'date': dateutil.parser.parse(e.updated),
2526 'feed': self._feed,
2627 'tags': [],
2728 }
29+ if entry['date'].tzinfo == None:
30+ entry['date'] = entry['date'].replace(tzinfo=dateutil.tz.tzutc())
2831 entries.append(entry)
2932 return entries
3033
--- a/gnews.py
+++ b/gnews.py
@@ -32,7 +32,11 @@ def main():
3232 tags[tag]['quoted_name'] = urllib.quote(tag.encode('utf-8'))
3333
3434 # sort by date
35- entries.sort(lambda x,y: -cmp(x["date"],y["date"]))
35+ cmp_entries = (lambda x,y: 1 if (x["date"] < y["date"]) else -1)
36+ entries.sort(cmp_entries)
37+
38+ for e in entries:
39+ print e["date"]
3640
3741 # Do rendering
3842 params = {'tags':tags, 'page':{}}
--- a/renderer.py
+++ b/renderer.py
@@ -11,8 +11,8 @@ from config import config, target_rss
1111 from propertizer import propertize
1212
1313 def date_format(date):
14- dt = dateutil.parser.parse(date)
15- return dt.strftime('%Y/%m/%d %H:%M')
14+ #dt = dateutil.parser.parse(date)
15+ return date.strftime('%Y/%m/%d %H:%M')
1616
1717 class Renderer(object):
1818 def __init__(self):