csev/py4e

gmodel.py: UnknownTimezoneWarning: tzname EDT identified but not understood

omicron-b opened this issue · 1 comments

pdate = parser.parse(md)
test_at = pdate.isoformat()

In Python 3.8.2 these lines cause a warning:

/usr/lib/python3/dist-packages/dateutil/parser/_parser.py:1199: UnknownTimezoneWarning: tzname EDT identified but not understood.  Pass `tzinfos` argument in order to correctly return a timezone-aware datetime.  In a future version, this will raise an exception.
  warnings.warn("tzname {tzname} identified but not understood.  "

This can be patched like this:

        if md.endswith('EDT'):
            md = md.replace('EDT','-0400')
        pdate = parser.parse(md)
        test_at = pdate.isoformat()

or like:

        if md.endswith('EDT'):
            md = md[:-3] + '-0400'
        pdate = parser.parse(md)
        test_at = pdate.isoformat()

Is explicitly replacing the last 3 symbols better?