Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

time-sugar

3.1.0 • Public • Published

Time Sugar

CircleCI

Some simple syntax for handling dates and times.

Usage

npm install time-sugar

Examples:

var T = require('time-sugar');
 
 
// Times
 
T(1).minute() == 60
T(5).minutes() == 300
 
T(60).minutes() == T(1).hour()
 
T(24).hours() == T(1).day()
T(48).hours() == T(2).days()
 
T(7).days() == T(1).week()
T(14).days() == T(2).weeks()
 
T(52).weeks() == T(1).year()
 
T(3).months() == T(0.25).years()
T(6).months() == T(0.5).years()
T(12).months() == T(1).year()
 
 
// Dates
var now = new Date();
 
T(1).day().fromNow()
T(2).weeks().fromNow()
 
T(1).day().beforeNow() // also: (1).day().ago()
T(3).weeks().beforeNow() // also: (3).weeks().ago()
 
T(1).day().from(now)
T(2).weeks().from(now)
 
T(1).day().before(now)
T(3).weeks().before(now)

Keywords

install

npm i time-sugar

Downloadsweekly downloads

76

version

3.1.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability