Package Exports
- @fetched/timeago
Readme
๐ช TIMEAGO
Tiniest Timeago Toolbox. Supports {ago | in}. Batteries Included.
- Localization โ English, Chinese, German, Spanish, French, Italian, Dutch, Japanese, Polish and Russian.
- Prefix โ Add a prefix string.
- Relative โ Use a relative date instead of the current time.
- Deadline โ Specify a
Date | string | numberdeadline after which aDate.toLocaleString()is displayed instead of thetimeagoformat. - Seconds โ Set
isSecondstotrueif you pass a seconds timestamp. Defaults tofalse. - Close Dates - Set closeDates to
trueif you want to displayToday/Tomorrow/Yesterdayinstead of theagoversion. Works only for time differences between 6 hours and 1 day, other times are displayed as usual. Defaults tofalse. - Browser supported.
- Node supported.
This package is inspired by Muffinman's blogpost. If you got some spare time, I highly recommed to check it out!
โจ INSTALLING
Using NPM:
npm i @fetched/timeago
Using PNPM:
pnpm install @fetched/timeago
Using YARN:
yarn add @fetched/timeago
Using CDN
<script src="https://www.unpkg.com/@fetched/timeago/dist/index.umd.js"></script>๐ USAGE
import { format } from '@fetched/timeago'
format(now)
// just now
format('2016-06-12')
// 7 years ago
format('2016-06-12', 'zh_CN')
// 7ๅนดๅ๐ ROADMAP
- Languages++
- Realtime
๐ป DEVELOPING
Run all tests:
npm run test
Build package with microbundle for production:
npm run build
๐จ CONTRIBUTING
Contributions for new languages are always welcome!
See examples for implementing a new language.