2.0.2 • Published 4 years ago

@t0ri/dates v2.0.2

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

Deights Library

Travis (.com) Coveralls github GitHub repo size

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'
2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.0

4 years ago