2020-08-26 00:01:38 +00:00
|
|
|
import utc from 'dayjs/plugin/utc';
|
2020-05-07 01:20:51 +00:00
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
2020-08-26 00:01:38 +00:00
|
|
|
dayjs.extend(utc);
|
|
|
|
|
2020-05-07 01:20:51 +00:00
|
|
|
const dateRanges = {
|
2020-05-14 02:26:05 +00:00
|
|
|
latest: () => ({
|
2020-09-11 00:29:14 +00:00
|
|
|
after: '1900-01-01',
|
|
|
|
before: dayjs.utc().toDate(),
|
2020-12-28 00:33:09 +00:00
|
|
|
orderBy: ['DATE_DESC', 'CREATED_AT_DESC'],
|
2020-05-14 02:26:05 +00:00
|
|
|
}),
|
|
|
|
upcoming: () => ({
|
2020-09-11 00:29:14 +00:00
|
|
|
after: dayjs.utc().toDate(),
|
|
|
|
before: '2100-01-01',
|
2020-12-28 00:33:09 +00:00
|
|
|
orderBy: ['DATE_ASC', 'CREATED_AT_ASC'],
|
2020-05-14 02:26:05 +00:00
|
|
|
}),
|
|
|
|
new: () => ({
|
2020-08-19 19:48:55 +00:00
|
|
|
after: '1900-01-01 00:00:00',
|
2020-09-11 00:29:14 +00:00
|
|
|
before: '2100-01-01',
|
2020-08-19 19:48:55 +00:00
|
|
|
orderBy: ['CREATED_AT_DESC', 'DATE_ASC'],
|
2020-05-14 02:26:05 +00:00
|
|
|
}),
|
|
|
|
all: () => ({
|
2020-09-11 00:29:14 +00:00
|
|
|
after: '1900-01-01',
|
|
|
|
before: '2100-01-01',
|
2020-12-28 00:33:09 +00:00
|
|
|
orderBy: ['DATE_DESC', 'CREATED_AT_DESC'],
|
2020-05-14 02:26:05 +00:00
|
|
|
}),
|
2020-05-07 01:20:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function getDateRange(range) {
|
2020-05-26 23:40:10 +00:00
|
|
|
return (dateRanges[range] || dateRanges.all)();
|
2020-05-07 01:20:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default getDateRange;
|