bark.py 文件源码

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

项目:bark 作者: kylerbrown 项目源码 文件源码
def convert_timestamp(obj, default_tz='America/Chicago'):
    """Makes a Bark timestamp from an object.

    If the object is not timezone-aware, the timezone is set to be `default_tz.`

    Args:
        obj: time object; see :meth:`timestamp_to_datetime` for supported types
        default_tz (str): timezone to use if `obj` is timezone-naive; must be a
            string from the `tz database
            <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>`_.

    Returns:
        Arrow: Bark timestamp
    """
    dt = timestamp_to_datetime(obj)
    if dt.tzinfo:
        return arrow.get(dt).isoformat()
    else:
        return arrow.get(dt, default_tz).isoformat()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号