util.py 文件源码

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

项目:smc-python 作者: gabstopper 项目源码 文件源码
def datetime_to_ms(dt):
    """
    Convert an unaware datetime object to milliseconds. This will
    be a UTC time. The SMC stores all times in UTC and will do the
    time conversions based on the local timezone.
    Example of converting a datetime to milliseconds::

        utc_time = datetime.strptime("2018-06-04T00:00:00", "%Y-%m-%dT%H:%M:%S")
        datetime_to_ms(utc_time)

    :param dt datetime: pass in python datetime object.
    :return: value representing the datetime in milliseconds
    :rtype: int
    """
    return int(time.mktime(dt.timetuple()) * 1000)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号