mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-10 18:27:25 +03:00
Ensured end dates are set at the end of the date when filtering visits
This commit is contained in:
parent
0e47f9b502
commit
178f15b7d3
1 changed files with 7 additions and 6 deletions
|
@ -55,6 +55,7 @@ export const rangeOrIntervalToString = (range?: DateRange | DateInterval): strin
|
|||
};
|
||||
|
||||
const startOfDaysAgo = (daysAgo: number) => startOfDay(subDays(new Date(), daysAgo));
|
||||
const endingToday = (startDate: Date): DateRange => ({ startDate, endDate: endOfDay(new Date()) });
|
||||
|
||||
export const intervalToDateRange = (dateInterval?: DateInterval): DateRange => {
|
||||
if (!dateInterval) {
|
||||
|
@ -63,19 +64,19 @@ export const intervalToDateRange = (dateInterval?: DateInterval): DateRange => {
|
|||
|
||||
switch (dateInterval) {
|
||||
case 'today':
|
||||
return { startDate: startOfDay(new Date()), endDate: new Date() };
|
||||
return endingToday(startOfDay(new Date()));
|
||||
case 'yesterday':
|
||||
return { startDate: startOfDaysAgo(1), endDate: endOfDay(subDays(new Date(), 1)) };
|
||||
case 'last7Days':
|
||||
return { startDate: startOfDaysAgo(7), endDate: new Date() };
|
||||
return endingToday(startOfDaysAgo(7));
|
||||
case 'last30Days':
|
||||
return { startDate: startOfDaysAgo(30), endDate: new Date() };
|
||||
return endingToday(startOfDaysAgo(30));
|
||||
case 'last90Days':
|
||||
return { startDate: startOfDaysAgo(90), endDate: new Date() };
|
||||
return endingToday(startOfDaysAgo(90));
|
||||
case 'last180days':
|
||||
return { startDate: startOfDaysAgo(180), endDate: new Date() };
|
||||
return endingToday(startOfDaysAgo(180));
|
||||
case 'last365Days':
|
||||
return { startDate: startOfDaysAgo(365), endDate: new Date() };
|
||||
return endingToday(startOfDaysAgo(365));
|
||||
}
|
||||
|
||||
return {};
|
||||
|
|
Loading…
Reference in a new issue