From: Tony Mack Date: Mon, 22 Nov 2010 18:17:25 +0000 (-0500) Subject: merge from jktest7 X-Git-Tag: sfa-1.0-9~16 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=0d9988520909b74d702b05a9ce63a36e7e41e2f1;p=sfa.git merge from jktest7 --- diff --git a/sfa/util/sfatime.py b/sfa/util/sfatime.py new file mode 100644 index 00000000..901b4e0d --- /dev/null +++ b/sfa/util/sfatime.py @@ -0,0 +1,10 @@ +import dateutil.parser + +def utcparse(str): + """ Translate a string into a time using dateutil.parser.parse but make sure it's in UTC time and strip + the timezone, so that it's compatible with normal datetime.datetime objects""" + + t = dateutil.parser.parse(str) + if not t.utcoffset() is None: + t = t.utcoffset() + t.replace(tzinfo=None) + return t