Collection of native Date utils to replace core moment functions.
npm install @taystack/get-dateMoment.js has been retired. It had math operations on dates. I think Math is helpful on Dates.
> With moment
``typescript`
import moment from 'moment'
const now = Date.now()
const today = moment.utc(now)
const momentYesterday = today.subtract(1, 'days')
> With @taystack/getDate:`typescript`
import { getDate, subtractDays } from '@taystack/get-date' // es6
// const { getDate, subtractDays } = require('@taystack/get-date') // es5
const now = Date.now()
const today = getDate(now)
const getDateYesterday = subtractDays(now, 1)
There are no dependencies. This is a small set of helpers for working with native Javascript Date objects.
bash
npm i @taystack/get-date
`API
- Getters
- getDate
- getDates
- getTime
- getDateInputValue
- getStartOfDay
- getTimeString
- Equality
- eq
- gt
- gte
- lt
- lte
- Math
- addDays
- addHours
- addMilliseconds
- addMinutes
- addSeconds
- addStep
- subtractDays
- subtractHours
- subtractMilliseconds
- subtractMinutes
- subtractSeconds
- subtractStep
- Humanize
- humanizeDay
- humanizeDifference
- humanizeMonth
- humanizeStep
- TimeDelta
- difference
- exclusiveRange
- inclusiveRange
- range
- helpers
- leftPad
- pluralize
Getters
$3
`typescript
import { getDate } from '@taystack/get-date'
getDate()
// Same as new Date()
getDate(0)
// new Date(0) -> jan 1 1970
`$3
`typescript
import { getTime } from '@taystack/get-date'
getTime()
// Same as Date.now()
getTime(0)
// 0 -> Short-hand new Date(0).getTime()
``