Deights Library

Create a Deight
Create a new Deight similar to creating a Date.
const date = new Deight('2/19/1998')
date.date -> 1998-02-19T08:00:00.000Z
Get Deight Values
Year
const date = new Deight('2/19/1998')
date.year -> 1998
Month
const date = new Deight('2/19/1998')
date.month -> 'February'
Day
const date = new Deight('2/19/1998')
date.month -> 'February'
Hours
const date = new Deight('2/19/1998 13:15:30')
date.hours -> 13
Minutes
const date = new Deight('2/19/1998 13:15:30')
date.minutes -> 15
Seconds
const date = new Deight('2/19/1998 13:15:30')
date.seconds -> 30
Format Mask
Deight objects can return their date and time formatted with many options.
const date = new Deight('2/19/1998 13:15:30')
date.format('M d, Y') -> 'February 19, 1998'
Format Key
'Y' -> 2019
'y' -> 19
'M' -> July
'm' -> Jul
'D' -> 01
'd' -> 1
'H' -> 05
'h' -> 5
'I' -> 08
'i' -> 8
'S' -> 04
's' -> 4
When
Deight's when()
method will return how many days, months, or years ago or until a given date.
const date = new Deight('2/19/1998 13:15:30')
date.when('2/22/1998') -> '3 days from now'
date.when('2/22/1997') -> '1 year ago'