mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Fix display of years.
This commit is contained in:
parent
84a8b51790
commit
a0cb278463
3 changed files with 6 additions and 3 deletions
|
|
@ -4,6 +4,7 @@ import {
|
|||
addHours,
|
||||
addDays,
|
||||
addMonths,
|
||||
addYears,
|
||||
subHours,
|
||||
subDays,
|
||||
startOfHour,
|
||||
|
|
@ -19,6 +20,7 @@ import {
|
|||
differenceInHours,
|
||||
differenceInCalendarDays,
|
||||
differenceInCalendarMonths,
|
||||
differenceInCalendarYears,
|
||||
} from 'date-fns';
|
||||
|
||||
export function getTimezone() {
|
||||
|
|
@ -90,7 +92,7 @@ export function getDateRangeValues(startDate, endDate) {
|
|||
return { startDate: startOfHour(startDate), endDate: endOfHour(endDate), unit: 'hour' };
|
||||
} else if (differenceInCalendarDays(endDate, startDate) <= 90) {
|
||||
return { startDate: startOfDay(startDate), endDate: endOfDay(endDate), unit: 'day' };
|
||||
} else if (differenceInCalendarMonths(endDate, startDate) <= 12) {
|
||||
} else if (differenceInCalendarMonths(endDate, startDate) <= 24) {
|
||||
return { startDate: startOfMonth(startDate), endDate: endOfMonth(endDate), unit: 'month' };
|
||||
}
|
||||
return { startDate: startOfYear(startDate), endDate: endOfYear(endDate), unit: 'year' };
|
||||
|
|
@ -100,6 +102,7 @@ const dateFuncs = {
|
|||
hour: [differenceInHours, addHours, startOfHour],
|
||||
day: [differenceInCalendarDays, addDays, startOfDay],
|
||||
month: [differenceInCalendarMonths, addMonths, startOfMonth],
|
||||
year: [differenceInCalendarYears, addYears, startOfYear],
|
||||
};
|
||||
|
||||
export function getDateArray(data, startDate, endDate, unit) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue