mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 14:47:14 +01:00
Calendar updates. Responsive CSS updates.
This commit is contained in:
parent
a0cb278463
commit
f59594e4cd
18 changed files with 127 additions and 42 deletions
21
lib/date.js
21
lib/date.js
|
|
@ -88,14 +88,16 @@ export function getDateRange(value) {
|
|||
}
|
||||
|
||||
export function getDateRangeValues(startDate, endDate) {
|
||||
if (differenceInHours(endDate, startDate) <= 48) {
|
||||
return { startDate: startOfHour(startDate), endDate: endOfHour(endDate), unit: 'hour' };
|
||||
let unit = 'year';
|
||||
if (differenceInHours(endDate, startDate) <= 72) {
|
||||
unit = 'hour';
|
||||
} else if (differenceInCalendarDays(endDate, startDate) <= 90) {
|
||||
return { startDate: startOfDay(startDate), endDate: endOfDay(endDate), unit: 'day' };
|
||||
unit = 'day';
|
||||
} else if (differenceInCalendarMonths(endDate, startDate) <= 24) {
|
||||
return { startDate: startOfMonth(startDate), endDate: endOfMonth(endDate), unit: 'month' };
|
||||
unit = 'month';
|
||||
}
|
||||
return { startDate: startOfYear(startDate), endDate: endOfYear(endDate), unit: 'year' };
|
||||
|
||||
return { startDate: startOfDay(startDate), endDate: endOfDay(endDate), unit };
|
||||
}
|
||||
|
||||
const dateFuncs = {
|
||||
|
|
@ -112,11 +114,12 @@ export function getDateArray(data, startDate, endDate, unit) {
|
|||
|
||||
function findData(t) {
|
||||
const x = data.find(e => {
|
||||
if (unit === 'day') {
|
||||
const [year, month, day] = e.t.split('-');
|
||||
return normalize(new Date(year, month - 1, day)).getTime() === t.getTime();
|
||||
if (unit === 'hour') {
|
||||
return normalize(new Date(e.t)).getTime() === t.getTime();
|
||||
}
|
||||
return normalize(new Date(e.t)).getTime() === t.getTime();
|
||||
|
||||
const [year, month, day] = e.t.split('-');
|
||||
return normalize(new Date(year, month - 1, day)).getTime() === t.getTime();
|
||||
});
|
||||
|
||||
return x?.y || 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue