lambda_setup.py 文件源码

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

项目:aws-greengrass-mini-fulfillment 作者: awslabs 项目源码 文件源码
def string_as_datetime(time_str):
    """Expects timestamps inline with '2017-06-05T22:45:24.423+0000'"""
    # split the utc offset part
    naive_time_str, offset_str = time_str[:-5], time_str[-5:]
    # parse the naive date/time part
    naive_dt = datetime.strptime(naive_time_str, '%Y-%m-%dT%H:%M:%S.%f')
    # parse the utc offset
    offset = int(offset_str[-4:-2]) * 60 + int(offset_str[-2:])
    if offset_str[0] == "-":
        offset = -offset
    dt = naive_dt.replace(tzinfo=FixedOffset(offset))
    return dt
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号