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
评论列表
文章目录