py4e icon indicating copy to clipboard operation
py4e copied to clipboard

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

Open omicron-b opened this issue 4 years ago • 1 comments

https://github.com/csev/py4e/blob/17b09f86773f96456a7d7e66cd1540b8294e0067/code3/gmane/gmodel.py#L59-L60

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()

omicron-b avatar Apr 12 '20 11:04 omicron-b

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?

omicron-b avatar Apr 12 '20 11:04 omicron-b