traxxx/assets/js/get-date-range.js

34 lines
724 B
JavaScript
Raw Normal View History

import utc from 'dayjs/plugin/utc';
import dayjs from 'dayjs';
dayjs.extend(utc);
const dateRanges = {
latest: () => ({
2020-08-19 19:48:55 +00:00
after: '1900-01-01 00:00:00',
before: dayjs.utc().format('YYYY-MM-DD HH:mm:ss'),
orderBy: 'DATE_DESC',
}),
upcoming: () => ({
after: dayjs.utc().format('YYYY-MM-DD HH:mm:ss'),
2020-08-19 19:48:55 +00:00
before: '2100-01-01 00:00:00',
orderBy: 'DATE_ASC',
}),
new: () => ({
2020-08-19 19:48:55 +00:00
after: '1900-01-01 00:00:00',
before: '2100-01-01 00:00:00',
orderBy: ['CREATED_AT_DESC', 'DATE_ASC'],
}),
all: () => ({
2020-08-19 19:48:55 +00:00
after: '1900-01-01 00:00:00',
before: '2100-01-01 00:00:00',
orderBy: 'DATE_DESC',
}),
};
function getDateRange(range) {
2020-05-26 23:40:10 +00:00
return (dateRanges[range] || dateRanges.all)();
}
export default getDateRange;