3.1.0 • Published 9 years ago

time-sugar v3.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

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)
3.1.0

9 years ago

3.0.0

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.0

10 years ago