My favorites
▼
|
Sign in
feedformatter
A Python library for generating news feeds in RSS and Atom formats
Project Home
Downloads
Wiki
Issues
Source
Export to GitHub
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
3
attachment: feedformatter-correct_datetime02.patch
(1.5 KB)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--- ../feedformatter-0.4/feedformatter.py 2009-06-09 08:07:50.000000000 -0400
+++ feedformatter.py 2011-05-06 15:32:01.670486000 -0400
@@ -27,6 +27,7 @@
__version__ = "0.4"
+import datetime
from cStringIO import StringIO
# This "staircase" of import attempts is ugly. If there's a nicer way to do
@@ -52,7 +53,7 @@
except ImportError:
feedformatterCanPrettyPrint = False
-from time import time, strftime, localtime, mktime, struct_time, timezone
+from time import time, strftime, strptime, localtime, mktime, struct_time, timezone
# RSS 1.0 Functions ----------
@@ -138,20 +141,19 @@
standard 9 part time tuple.
"""
- if (type(time) is tuple and len(time) ==9) or type(time) is struct_time:
+ if type(time) is datetime.datetime:
+ return time.timetuple()
+ elif (type(time) is tuple and len(time) ==9) or type(time) is struct_time:
# Already done!
return time
elif type(time) is int or type(time) is float:
# Assume this is a seconds-since-epoch time
return localtime(time)
- elif type(time) is str:
- if time.isalnum():
- # String is alphanumeric - a time stamp?
+ elif type(time) in types.StringTypes:
+ # A time stamp?
try:
return strptime(time, "%a, %d %b %Y %H:%M:%S %Z")
except ValueError:
- raise Exception("Unrecongised time format!")
- else:
# Maybe this is a string of an epoch time?
try:
return localtime(float(time))
Powered by
Google Project Hosting