util.py 文件源码

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

项目:kotori 作者: daq-tools 项目源码 文件源码
def parse_timestamp(timestamp):

    if isinstance(timestamp, text_type):

        # HACK: Assume CET (Europe/Berlin) for human readable timestamp w/o timezone offset
        qualified = any([token in timestamp for token in ['Z', '+', ' CET', ' CEST']])
        if not qualified:
            timestamp += ' CET'

        # Parse datetime string
        # Remark: Maybe use pandas.tseries.tools.parse_time_string?
        # TODO: Cache results of call to gettz to improve performance
        berlin = gettz('Europe/Berlin')
        tzinfos = {'CET': berlin, 'CEST': berlin}
        timestamp = parse(timestamp, tzinfos=tzinfos)

    return timestamp
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号