mirror of
https://github.com/kremalicious/umami.git
synced 2025-01-05 11:35:09 +01:00
feature(lib): locale option for getDateRange
This commit is contained in:
parent
17836c70e7
commit
eb1029bfc8
@ -36,8 +36,9 @@ export function getLocalTime(t) {
|
|||||||
return addMinutes(new Date(t), new Date().getTimezoneOffset());
|
return addMinutes(new Date(t), new Date().getTimezoneOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDateRange(value) {
|
export function getDateRange(value, locale) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
const localeOptions = dateLocales[locale];
|
||||||
|
|
||||||
const { num, unit } = value.match(/^(?<num>[0-9]+)(?<unit>hour|day|week|month|year)$/).groups;
|
const { num, unit } = value.match(/^(?<num>[0-9]+)(?<unit>hour|day|week|month|year)$/).groups;
|
||||||
|
|
||||||
@ -52,8 +53,8 @@ export function getDateRange(value) {
|
|||||||
};
|
};
|
||||||
case 'week':
|
case 'week':
|
||||||
return {
|
return {
|
||||||
startDate: startOfWeek(now),
|
startDate: startOfWeek(now, { locale: localeOptions }),
|
||||||
endDate: endOfWeek(now),
|
endDate: endOfWeek(now, { locale: localeOptions }),
|
||||||
unit: 'day',
|
unit: 'day',
|
||||||
value,
|
value,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user