hustcc / Timeago
Licence: mit
⌛️ Simple library used to format datetime with `*** time ago` statement. eg: "3 hours ago".
Stars: ✭ 183
Programming Languages
python
139335 projects - #7 most used programming language
Labels
Projects that are alternatives of or similar to Timeago
Timeago.js
🕗 ⌛ timeago.js is a tiny(2.0 kb) library used to format date with `*** time ago` statement.
Stars: ✭ 4,670 (+2451.91%)
Mutual labels: multi-language, datetime
Libfaketime
libfaketime modifies the system time for a single application
Stars: ✭ 1,932 (+955.74%)
Mutual labels: datetime
Pyjson tricks
Extra features for Python's JSON: comments, order, numpy, pandas, datetimes, and many more! Simple but customizable.
Stars: ✭ 131 (-28.42%)
Mutual labels: datetime
Node Geo Tz
A node.js module to find the timezone based on gps coordinates
Stars: ✭ 181 (-1.09%)
Mutual labels: datetime
Exceptionless.datetimeextensions
DateTimeRange, Business Day and various DateTime, DateTimeOffset, TimeSpan extension methods
Stars: ✭ 142 (-22.4%)
Mutual labels: datetime
React Date Range
A React component for choosing dates and date ranges.
Stars: ✭ 2,052 (+1021.31%)
Mutual labels: datetime
Tail.datetime
A lightweight, translat- and configurable Open Source DateTime Picker, written in pure vanilla JavaScript!
Stars: ✭ 139 (-24.04%)
Mutual labels: datetime
Holidaydatetime
A php class to check Japanese holiday and weekend. 土日祝日を判定するphpクラス。
Stars: ✭ 153 (-16.39%)
Mutual labels: datetime
Luxon
⏱ A library for working with dates and times in JS
Stars: ✭ 11,926 (+6416.94%)
Mutual labels: datetime
Eztime
ezTime — pronounced "Easy Time" — is a very easy to use Arduino time and date library that provides NTP network time lookups, extensive timezone support, formatted time and date strings, user events, millisecond precision and more.
Stars: ✭ 173 (-5.46%)
Mutual labels: datetime
Persiandate4mysql
pDate is a Gregorian / Jalali(Shamsi) date convertor functions for MySQL 5.1+
Stars: ✭ 131 (-28.42%)
Mutual labels: datetime
Date Picker
📅 Custom responsive date picker widget for Android, written in Kotlin.
Stars: ✭ 146 (-20.22%)
Mutual labels: datetime
Date
A date and time library based on the C++11/14/17 <chrono> header
Stars: ✭ 2,389 (+1205.46%)
Mutual labels: datetime
Anydate
Swifty Date & Time API inspired from Java 8 DateTime API.
Stars: ✭ 178 (-2.73%)
Mutual labels: datetime
timeago
A very simple python lib, used to format datetime with *** time ago
statement. Javascript version here. timeago.js.
Such as:
just now
12 seconds ago
3 minutes ago
2 hours ago
24 days ago
6 months ago
2 years ago
in 12 seconds
in 3 minutes
in 2 hours
in 24 days
in 6 months
in 2 years
For other languages see below.
Install
pip install timeago
Usage & Example
# -*- coding: utf-8 -*-
import timeago, datetime
now = datetime.datetime.now() + datetime.timedelta(seconds = 60 * 3.4)
date = datetime.datetime.now()
# locale
print (timeago.format(date, now, 'zh_CN')) # will print `3分钟前`
# input datetime
print (timeago.format(date, now)) # will print 3 minutes ago
# input timedelta
print (timeago.format(datetime.timedelta(seconds = 60 * 3.4))) # will print 3 minutes ago
# input date, auto add time(0, 0, 0)
print (timeago.format(datetime.date(2016, 5, 27), now))
# input datetime formatted string
print (timeago.format('2016-05-27 12:12:03', '2016-05-27 12:12:12')) # will print just now
# inverse two parameters
print (timeago.format('2016-05-27 12:12:12', '2016-05-27 12:12:03')) # will print a while
Method & Parameter
only one API format
.
Three parameters of method format
:
-
date
: the parameter which will be formatted, must be instance ofdatetime
/timedelta
or datetime formatted string. -
now
: reference time, must be instance ofdatetime
or datetime formatted string. -
locale
: the locale code, defaulten
.
Locale
At the time we're speaking, following locale are available:
ar
bg
ca
da
de
el
en
en_short
es
eu
fa_IR
fi
fr
gl
guj_IN
he
hu
in_BG
in_HI
in_ID
is
it
ja
ko
lt
ml
my
nb_NO
nl
nn_NO
pl
pt_BR
pt_PT
ro
ru
sv_SE
ta
th
tr
uk
vi
zh_CN
zh_TW
Localization
- Fork the project
- Create a locale python script called
[name_of_your_locale].py
following the existing other locales. - Add the name of your locale in the Readme (both in MD and in RST) to keep it updated (alphabetically).
- Add test case following the english model
- Create the Pull Request.
Notes
For complicated plurals, you can take example on the PL :flag-pl: locale here
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].