Permalink
Browse files

Fixes issue #3.

git-svn-id: http://feedformatter.googlecode.com/svn/trunk@15 a65a53d6-54cd-11de-8ef9-cf35a3c3eb08
  • Loading branch information...
1 parent 38c066d commit 120bc967a2660e5c63895e3da377d8b8fb813029 michael573114@gmail.com committed May 7, 2011
Showing with 7 additions and 7 deletions.
  1. +7 −7 feedformatter.py
View
@@ -54,7 +54,8 @@
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
+import datetime
# RSS 1.0 Functions ----------
@@ -140,20 +141,19 @@ def _convert_datetime(time):
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))

0 comments on commit 120bc96

Please sign in to comment.