Skip to content

πŸͺ„ Tiniest `time ago` Toolbox. Supports {ago|in}. Batteries Included.

License

Notifications You must be signed in to change notification settings

FFGlobal/timeago

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸͺ„ 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 | number deadline after which a Date.toLocaleString() is displayed instead of the timeago format.
  • Seconds β€” Set isSeconds to true if you pass a seconds timestamp. Defaults to false.
  • Close Dates - Set closeDates to true if you want to display Today/Tomorrow/Yesterday instead of the ago version. Works only for time differences between 6 hours and 1 day, other times are displayed as usual. Defaults to false.
  • 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.

πŸ₯‚ LICENSE

MIT License