Dad
pronounces like "Date"
- Humans readable code
- Easy for testing
- Works in Node and Browser
$ yarn add github:17media/dad\#latest
dad
's API interface always input seconds
and return seconds
import dad from '@17media/dad'
dad('2017-12-12').tw
// or
import { tw } from '@17media/dad'
tw('2017-12-12')
// 1513036800
tw(1514736000)
// {
// year: 2018,
// month: 0,
// date: 1,
// hours: 0,
// minutes: 0,
// seconds: 0,
// day: 1
// }
tw(1514736000).format('YYYY/MM/DD hh:mm:ss') // 2018/01/01 00:00:00
YYYY-MM-DD
YYYY-MM-DD HH
YYYY-MM-DD HH:mm
YYYY-MM-DD HH:mm:ss
You can omit HH:mm:ss
, dad will help you auto suffix 00
.
Current works regions for event:
tw
, hk
and ja
Check seconds timestamp whether same as Today, this is helpful for vote feature.
now
is very useful for testing, you can feel free to hard-code current time.
In Browser, pass URL querystring:
?dad.now=2017-12-12 19:00
In Node:
$ ndoe entry.js --dad.now="2017-12-12 19:00"
pass --auto
lets time go on:
In Browser:
?dad.now=2017-12-12 19:00&auto
In Node:
$ ndoe entry.js --dad.now=2017-12-12T19:00 --auto