From 0d9988520909b74d702b05a9ce63a36e7e41e2f1 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Mon, 22 Nov 2010 13:17:25 -0500 Subject: [PATCH] merge from jktest7 --- sfa/util/sfatime.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 sfa/util/sfatime.py 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 -- 2.47.0