Giter Club home page Giter Club logo

yields-approximate-time's Introduction

This repository is a mirror of the component module yields/approximate-time. It has been modified to work with NPM+Browserify. You can install it using the command npm install npmcomponent/yields-approximate-time. Please do not open issues or send pull requests against this repo. If you have issues with this repo, report it to npmcomponent.

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.