Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

approximate-time

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

approximate-time

approximate human readable time

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

approximate-time

approximate human readable time

Installation

Install with component(1):

$ component install yields/approximate-time

API

approximate(date)

Get approximate human readable time with date.

Examples

var time = require('approximate-time');

// now
assert('just now' == time(new Date));

// seconds
assert('a second' == time(add(1e3)));
assert('5 seconds' == time(add(1e3 * 5)));

// minutes
assert('a minute' == time(add(1e3 * 60)));
assert('5 minutes' == time(add(6e4 * 5)));

// hours
assert('an hour' == time(add(6e4 * 60)));
assert('5 hours' == time(add(3.6e+6 * 5)));

// days
assert('a day' == time(add(3.6e+6 * 24)));
assert('5 days' == time(add(8.64e+7 * 5)));

// weeks
assert('a week' == time(add(8.64e+7 * 7)));
assert('3 weeks' == time(add(6.048e+8 * 3)));

// months
assert('a month' == time(add(6.048e+8 * 4.4)));
assert('5 months' == time(add(2.63e+9 * 5)));

// years
assert('a year' == time(add(2.63e+9 * 12)));
assert('5 years' == time(add(3.156e+10 * 5)));

// decades
assert('a decade' == time(add(3.156e+10 * 10)));
assert('5 decades' == time(add(3.156e+11 * 5)));
assert('100 decades' == time(sub(3.156e+11 * 100)));

License

MIT

Keywords

FAQs

Package last updated on 22 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc