forked from DebaucheryLibrarian/traxxx
31 lines
660 B
JavaScript
31 lines
660 B
JavaScript
import dayjs from 'dayjs';
|
|
|
|
const dateRanges = {
|
|
latest: () => ({
|
|
after: '1900-01-01 00:00:00',
|
|
before: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
orderBy: 'DATE_DESC',
|
|
}),
|
|
upcoming: () => ({
|
|
after: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
before: '2100-01-01 00:00:00',
|
|
orderBy: 'DATE_ASC',
|
|
}),
|
|
new: () => ({
|
|
after: '1900-01-01 00:00:00',
|
|
before: '2100-01-01 00:00:00',
|
|
orderBy: ['CREATED_AT_DESC', 'DATE_ASC'],
|
|
}),
|
|
all: () => ({
|
|
after: '1900-01-01 00:00:00',
|
|
before: '2100-01-01 00:00:00',
|
|
orderBy: 'DATE_DESC',
|
|
}),
|
|
};
|
|
|
|
function getDateRange(range) {
|
|
return (dateRanges[range] || dateRanges.all)();
|
|
}
|
|
|
|
export default getDateRange;
|