ewsdatetime.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:exchangelib 作者: ecederstrand 项目源码 文件源码
def localize(self, dt, is_dst=False):
        # super() returns a dt.tzinfo of class pytz.tzinfo.FooBar. We need to return type EWSTimeZone
        if is_dst is not False:
            # Not all pytz timezones support 'is_dst' argument. Only pass it on if it's set explicitly.
            try:
                res = super(EWSTimeZone, self).localize(dt, is_dst=is_dst)
            except pytz.exceptions.AmbiguousTimeError:
                raise AmbiguousTimeError(str(dt))
            except pytz.exceptions.NonExistentTimeError:
                raise NonExistentTimeError(str(dt))
        else:
            res = super(EWSTimeZone, self).localize(dt)
        if not isinstance(res.tzinfo, EWSTimeZone):
            return res.replace(tzinfo=self.from_pytz(res.tzinfo))
        return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号