timeago

A python lib format datetime to *** time ago. https://github.com/hustcc/timeago

Build Status PyPi Status Python Versions PyPi Downloads

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:

  • date: datetime will be done / format.

  • now: reference time, must be instance of datetime.

  • locale: the locale code, only zh_CN / en supported, default en.

Localization

  1. foke the project

  2. add <locale>.py file in the locales folder.

  3. pull a request.


hustcc
933 声望88 粉丝

前端攻城军