def from_timestring_to_utctimestamp(self, timestamp, type=None):
# Sigh, TrainPredictions include seconds, BusPredictions don't
if type == 'train':
timestr_format = "%Y%m%d %H:%M:%S"
else:
timestr_format = "%Y%m%d %H:%M"
local_datetime = datetime.strptime(timestamp, timestr_format).replace(tzinfo=tz.tzlocal())
return (local_datetime - datetime(1970, 1, 1, tzinfo=tz.tzutc())).total_seconds()
评论列表
文章目录