summaryrefslogtreecommitdiff
path: root/dateutil/parser/_parser.py
diff options
context:
space:
mode:
authorParseThis <orson.network@gmail.com>2018-04-14 14:57:26 -0400
committerPaul Ganssle <paul@ganssle.io>2018-04-19 20:37:09 -0400
commit6b923f3129a91e5ed207112346e03e796f1cf3f5 (patch)
tree0c911ca05d4d73b0734193a1746697822ec5f7e7 /dateutil/parser/_parser.py
parent194a8e83f0f6544b12e1858da767fac833da7666 (diff)
downloaddateutil-git-6b923f3129a91e5ed207112346e03e796f1cf3f5.tar.gz
Allow user to specify None as tzinfo value
This commit allows the user to specify None when the dont care about the time zone information in the date time parse.
Diffstat (limited to 'dateutil/parser/_parser.py')
-rw-r--r--dateutil/parser/_parser.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/dateutil/parser/_parser.py b/dateutil/parser/_parser.py
index 79cd2bb..f749bdf 100644
--- a/dateutil/parser/_parser.py
+++ b/dateutil/parser/_parser.py
@@ -1125,16 +1125,14 @@ class parser(object):
tzdata = tzinfos(tzname, tzoffset)
else:
tzdata = tzinfos.get(tzname)
-
- if isinstance(tzdata, datetime.tzinfo):
+ # handle case where tzinfo is paased an options that returns None
+ # eg tzinfos = {'BRST' : None}
+ if isinstance(tzdata, datetime.tzinfo) or tzdata is None:
tzinfo = tzdata
elif isinstance(tzdata, text_type):
tzinfo = tz.tzstr(tzdata)
elif isinstance(tzdata, integer_types):
tzinfo = tz.tzoffset(tzname, tzdata)
- else:
- raise ValueError("Offset must be tzinfo subclass, "
- "tz string, or int offset.")
return tzinfo
def _build_tzaware(self, naive, res, tzinfos):
@@ -1170,7 +1168,7 @@ class parser(object):
warnings.warn("tzname {tzname} identified but not understood. "
"Pass `tzinfos` argument in order to correctly "
"return a timezone-aware datetime. In a future "
- "version, this raise an "
+ "version, this will raise an "
"exception.".format(tzname=res.tzname),
category=UnknownTimezoneWarning)
aware = naive