util.py 文件源码

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

项目:pypond 作者: esnet 项目源码 文件源码
def humanize_dt_ago(dtime):
    """format to "23 minutes ago" style format.

    Parameters
    ----------
    dtime : datetime.datetime
        A datetime object

    Returns
    -------
    str
        Humanized string.
    """
    # and here we went through all the trouble to make everything
    # UTC and offset-aware. Le sigh. The underlying lib uses datetime.now()
    # as the comparison reference, so we need naive localtime.
    return humanize.naturaltime(dtime.astimezone(LOCAL_TZ).replace(tzinfo=None))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号