From: Tony Mack Date: Fri, 6 Jan 2012 18:31:57 +0000 (-0500) Subject: try casting strings to ints before parsing X-Git-Tag: sfa-2.0-9~9 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=3ab0d9564822ed3e3f34aaf0c0051074d9e2332a;p=sfa.git try casting strings to ints before parsing --- diff --git a/sfa/util/sfatime.py b/sfa/util/sfatime.py index 478c5bee..c5d5afaf 100644 --- 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