catamphetamine / javascript-time-ago

International highly customizable relative date/time formatting

Home Page:https://catamphetamine.gitlab.io/react-time-ago/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use english.tiny

lukakerr opened this issue · comments

I've read the docs and see theres a time style of english.tiny:

english.tiny  // '1s', '2m', '3h', '4d', …

How do you use this style? I've tried:

import TimeAgo from 'javascript-time-ago';
import english from 'javascript-time-ago/locale/en';

TimeAgo.locale(english);
const timeAgo = new TimeAgo('en-US');

timeAgo.format(Date.now() - 60 * 1000, 'tiny');

but it isn't working. It just gives a long date such as: 2 hours ago.

Nevermind, got it. You need to pass an object:

timeAgo.format(Date.now() - 60 * 1000, { flavour: 'tiny' });

Yeah, I updated the readme a bit describing style
https://github.com/catamphetamine/javascript-time-ago#customization

Rewrote the customization section again.