def parse_date(date1, date2):
# edge-case for feed
# pubdate is assumed to be a time.struct_time here
pubdate_fmt = None
pubdate = date1
if pubdate:
try:
pubdate_fmt = strftime('%Y-%m-%d %H:%M:%S +0000',pubdate)
except Exception, e:
print e
pubdate = None
# edge-case for atom feed
# e.get('updated') 2011-02-01T20:21:42+00:00
pubdate = date2
if pubdate and not pubdate_fmt:
try:
i1 = pubdate[:19]
i1 = datetime.strptime(i1, "%Y-%m-%dT%H:%M:%S")
pubdate_fmt = i1.strftime('%Y-%m-%d %H:%M:%S +0000')
except Exception, e:
print e
pubdate = None
return pubdate_fmt
评论列表
文章目录