From 3ab0d9564822ed3e3f34aaf0c0051074d9e2332a Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Fri, 6 Jan 2012 13:31:57 -0500 Subject: [PATCH] try casting strings to ints before parsing --- sfa/util/sfatime.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -- 2.43.0