utils.py 文件源码

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

项目:django-anymail 作者: anymail 项目源码 文件源码
def parsedate_to_datetime(s):
        # *dtuple, tz = _parsedate_tz(data)
        dtuple = parsedate_tz(s)
        tz = dtuple[-1]
        # if tz is None:  # parsedate_tz returns 0 for "-0000"
        if tz is None or (tz == 0 and "-0000" in s):
            # "... indicates that the date-time contains no information
            # about the local time zone" (RFC 2822 #3.3)
            return datetime(*dtuple[:6])
        else:
            # tzinfo = datetime.timezone(datetime.timedelta(seconds=tz))  # Python 3.2+ only
            tzinfo = get_fixed_timezone(tz // 60)  # don't use timedelta (avoid Django bug #28739)
            return datetime(*dtuple[:6], tzinfo=tzinfo)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号