a-while-ago
v1.0.1
Published
It happened a while ago
Downloads
24
Maintainers
Readme
Install
$ npm install a-while-ago
Usage
const awa = require('a-while-ago');
console.log(awa(new Date() - 1000));
// => a second ago
API
awa(date)
- date: A past date
Example:
awa(new Date() - 1000)
// => a second ago
awa(new Date() - 60 * 2000);
// => 2 minutes ago
awa(date, short)
- date: A past date
- short (
boolean
): A past date
Example:
awa(new Date() - 60 * 2000, true);
// => 2m
Related
- minutes-to-read: How long does it take you to read something.
Todo
- Support for sufix object instead of a boolean value.
Current:
awa(new Date() - 60 * 2000, true);
// => 2m
Desired behavior
awa(new Date() - 60 * 2000, { short: true });
// => 2m
awa(new Date() - 60 * 2000, { short: false });
// => 2 minutes ago
License
MIT License © Carlos Abraham