git://git.onelab.eu
/
sfa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0f50c1d
)
try casting strings to ints before parsing
author
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Fri, 6 Jan 2012 18:31:57 +0000
(13:31 -0500)
committer
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Fri, 6 Jan 2012 18:31:57 +0000
(13:31 -0500)
sfa/util/sfatime.py
patch
|
blob
|
history
diff --git
a/sfa/util/sfatime.py
b/sfa/util/sfatime.py
index
478c5be
..
c5d5afa
100644
(file)
--- a/
sfa/util/sfatime.py
+++ b/
sfa/util/sfatime.py
@@
-13,7
+13,14
@@
the timezone, so that it's compatible with normal datetime.datetime objects.
For safety this can also handle inputs that are either timestamps, or datetimes
"""
-
+ # perpare the input for the checks below by
+ # casting strings ('1327098335') to ints
+ if isinstance(input, StringTypes):
+ try:
+ input = int(input)
+ except ValueError:
+ pass
+
if isinstance (input, datetime.datetime):
logger.warn ("argument to utcparse already a datetime - doing nothing")
return input