Running this with the TZ environment set to US/Eastern:
>>> from dateutil import parser, tz
>>> dt = parser.parse('2011-11-06 01:30:00 EST')
>>> dt.tzname()
'EDT'
>>> tz.enfold(dt, fold=1).tzname()
'EST'
This is a situation where we start with an unambiguous date but because of how the tzlocal() parsing works, end up with an ambiguous date. Right now this mainly affects tzlocal() but it may also be useful in this situation:
>>> from dateutil import parser, tz
>>> tzinfos = {'EDT': tz.gettz('US/Eastern'), 'EST': tz.gettz('US/Eastern')}
>>> dt = parser.parse('2011-11-06 01:03:00 EST', tzinfos=tzinfos)
>>> dt.tzname()
'EDT'
This last one is dubious because it's not guaranteed that the tzname is going to match one of the keywords, but it's probably worth trying when the date is ambiguous, just in case. That said, if you're specifying tzinfos, you might as well just specify tzoffset values and then use .astimezone() to convert to whatever time zone you actually want to be in.
Running this with the TZ environment set to
US/Eastern:This is a situation where we start with an unambiguous date but because of how the
tzlocal()parsing works, end up with an ambiguous date. Right now this mainly affectstzlocal()but it may also be useful in this situation:This last one is dubious because it's not guaranteed that the
tznameis going to match one of the keywords, but it's probably worth trying when the date is ambiguous, just in case. That said, if you're specifyingtzinfos, you might as well just specifytzoffsetvalues and then use.astimezone()to convert to whatever time zone you actually want to be in.