const [date, dateDispatch] = useDate(configs)
//implented with [`date-fns`](https://date-fns.org/)
name | type | default | description |
---|---|---|---|
defaultDate | Date Object | string | null | |
formatPattern | string | yyyy-MM-dd | see date-fns doc |
transitionUnit | string | days | see date-fns doc |
offsetUnit | string | days | see date-fns doc |
offsetValue | number | 0 |
name | type | description |
---|---|---|
date | string | |
dateDispatch | function | dateDispatch(type, payload), see below |
dateDispatch(type, payload)
type | payload | description |
---|---|---|
BACKWARD | number | void | payload default as 1 when not provided |
FORWARD | number | void | payload default as 1 when not provided |
NOW |
| To NOW |
TO | Date Object | string | To specific date |
Date: 2024-11-21
const defaultConfigs = {
defaultDate: null,
formatPattern: "yyyy-MM-dd",
transitionUnit: "days",
offsetUnit: "days",
offsetValue: 0,
}
Date: 2022-08-28
const defaultConfigs = {
defaultDate: "2022-08-30",
formatPattern: "yyyy-MM-dd",
transitionUnit: "months",
offsetUnit: "days",
offsetValue: -2,
}