35 lines
758 B
JavaScript
35 lines
758 B
JavaScript
import dayjs from 'dayjs';
|
|
|
|
const dateRanges = {
|
|
new: () => ({
|
|
after: dayjs(new Date(0)).format('YYYY-MM-DD'),
|
|
before: dayjs(new Date()).format('YYYY-MM-DD'),
|
|
}),
|
|
upcoming: () => ({
|
|
after: dayjs(new Date()).format('YYYY-MM-DD'),
|
|
before: dayjs(new Date(2 ** 42)).format('YYYY-MM-DD'),
|
|
}),
|
|
all: () => ({
|
|
after: dayjs(new Date(0)).format('YYYY-MM-DD'),
|
|
before: dayjs(new Date(2 ** 42)).format('YYYY-MM-DD'),
|
|
}),
|
|
};
|
|
|
|
function rangeDates(state) {
|
|
return dateRanges[state.range]();
|
|
}
|
|
|
|
function before(state) {
|
|
return dateRanges[state.range]().before;
|
|
}
|
|
|
|
function after(state) {
|
|
return dateRanges[state.range]().after;
|
|
}
|
|
|
|
export default {
|
|
rangeDates,
|
|
before,
|
|
after,
|
|
};
|