刚撸的一个 python 库 timeago

2016-05-26 13:23:26 +08:00
 50vip

看名字应该就知道是什么意思了,就是将时间转化成多少多少时间之前。很多网站都会用到的。

github 地址:https://github.com/hustcc/timeago 下面直接是 readme 内容。

发布到 pipy 了,直接 pip install timeago 即可体验。

timeago

A python lib format datetime to *** time ago.

Install

pip install timeago

Usage & Example

import timeago, datetime

now = datetime.datetime.now() + datetime.timedelta(seconds = 60 * 3.4)

print (timeago.format(date, now)) # will print 3 minutes ago

Methor & Parameter

only one API format.

Three parameters of method format:

Localization

  1. foke the project
  2. add <locale>.py file in the locales folder.
  3. pull a request.
2035 次点击
所在节点    分享创造
1 条回复
gogobody
2016-05-27 16:00:20 +08:00
支持~

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/281399

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX