UnknownTimezoneWarning:识别出tzname PDT,但无法理解。传递tzinfos参数以正确返回时区感知日期时间

时间:2018-08-24 16:30:38

标签: python-2.7

有人可以帮助我解决这个问题吗?我正在尝试获取AWS RSS信息并将其提供给Zabbix。

  

usr / lib / python2.7 / site-packages / dateutil / parser / _parser.py:1204:UnknownTimezoneWarning:tzname PDT已识别,但无法理解。传递tzinfos参数,以正确返回时区感知日期时间。在将来的版本中,这将引发异常。    category = UnknownTimezone警告)

来自_parser.py:

def _build_tzaware(self, naive, res, tzinfos):
        if (callable(tzinfos) or (tzinfos and res.tzname in tzinfos)):
            tzinfo = self._build_tzinfo(tzinfos, res.tzname, res.tzoffset)
            aware = naive.replace(tzinfo=tzinfo)
            aware = self._assign_tzname(aware, res.tzname)

        elif res.tzname and res.tzname in time.tzname:
            aware = naive.replace(tzinfo=tz.tzlocal())

            # Handle ambiguous local datetime
            aware = self._assign_tzname(aware, res.tzname)

            # This is mostly relevant for winter GMT zones parsed in the UK
            if (aware.tzname() != res.tzname and
                    res.tzname in self.info.UTCZONE):
                aware = aware.replace(tzinfo=tz.tzutc())

        elif res.tzoffset == 0:
            aware = naive.replace(tzinfo=tz.tzutc())

        elif res.tzoffset:
            aware = naive.replace(tzinfo=tz.tzoffset(res.tzname, res.tzoffset))

        elif not res.tzname and not res.tzoffset:
            # i.e. no timezone information was found.
            aware = naive

        elif res.tzname:
            # tz-like string was parsed but we don't know what to do
            # with it
            warnings.warn("tzname {tzname} identified but not understood.  "
                          "Pass `tzinfos` argument in order to correctly "
                          "return a timezone-aware datetime. 

完整代码在这里:https://github.com/tech-sketch/zabbix_aws_template/blob/master/scripts/AWS_Service_Health_Dashboard.py

0 个答案:

没有答案