a-while-ago
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published


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

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

Package Sidebar

Install

npm i a-while-ago

Weekly Downloads

5

Version

1.0.1

License

MIT

Unpacked Size

5.04 kB

Total Files

6

Last publish

Collaborators

  • abranhe