mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 22:27:16 +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;
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ export const menuOptions = [
|
|||
{ label: 'Nederlands (Dutch)', value: 'nl-NL', display: 'NL' },
|
||||
{ label: 'Deutsch (German)', value: 'de-DE', display: 'DE' },
|
||||
{ label: '日本語 (Japanese)', value: 'ja-JP', display: '日本語' },
|
||||
{ label: 'Español (Mexicano)', value: 'es-MX', display: 'ES' },
|
||||
{ label: 'Русский (Russian)', value: 'ru-RU', display: 'РУ' },
|
||||
{ label: 'Turkish', value: 'tr-TR', display: 'TR' },
|
||||
{ label: 'Español (Mexicano)', value: 'es-MX', display: 'ES' },
|
||||
];
|
||||
|
||||
export function dateFormat(date, str, locale) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue