serializers.py 文件源码

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

项目:pytennessee 作者: lorenanicole 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号