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))
评论列表
文章目录