Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67614 - website/public_html/beta/feed
From: dnljms_at_[hidden]
Date: 2011-01-03 07:52:51


Author: danieljames
Date: 2011-01-03 07:52:38 EST (Mon, 03 Jan 2011)
New Revision: 67614
URL: http://svn.boost.org/trac/boost/changeset/67614

Log:
Fix date parsing for timezones.

And fail loudly if something goes wrong - it was failing silently.

Text files modified:
   website/public_html/beta/feed/bbook2rss.py | 28 ++++++++++++++--------------
   1 files changed, 14 insertions(+), 14 deletions(-)

Modified: website/public_html/beta/feed/bbook2rss.py
==============================================================================
--- website/public_html/beta/feed/bbook2rss.py (original)
+++ website/public_html/beta/feed/bbook2rss.py 2011-01-03 07:52:38 EST (Mon, 03 Jan 2011)
@@ -11,6 +11,7 @@
 import os.path
 import hashlib
 import codecs
+from email.utils import parsedate_tz
 
 class RssUpdateCheck:
     """ Tracks which items in an rss feed have been updated.
@@ -160,20 +161,19 @@
                 item = self.x(article.documentElement)
 
             if item:
- try:
- last_modified = item.getElementsByTagName('pubDate')[0]
- last_modified = " ".join(
- t.nodeValue for t in last_modified.childNodes
- if t.nodeType == t.TEXT_NODE)
- last_modified = last_modified.replace(',', ' ')
- items.append([
- time.mktime(time.strptime(last_modified,
- '%a %d %b %Y %H:%M:%S %Z')),
- item,
- bb
- ])
- except:
- items.append([time.time(),item,bb])
+ last_modified = item.getElementsByTagName('pubDate')[0]
+ last_modified = " ".join(
+ t.nodeValue for t in last_modified.childNodes
+ if t.nodeType == t.TEXT_NODE)
+ last_modified = last_modified.replace(',', ' ').strip()
+
+ if not last_modified or last_modified[0] == '$':
+ last_modified_time = time.time()
+ else:
+ last_modified_time = parsedate_tz(last_modified)
+ last_modified_time = time.mktime(last_modified_time[:-1]) - last_modified_time[-1]
+
+ items.append([last_modified_time, item, bb])
                 
         self.new_hashes = RssUpdateCheck()
         items.sort(lambda x,y: -cmp(x[0],y[0]))


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk