mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 07:13:37 +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());
|
||||
}
|
||||
|
||||
export function getDateRange(value) {
|
||||
export function getDateRange(value, locale) {
|
||||
const now = new Date();
|
||||
const localeOptions = dateLocales[locale];
|
||||
|
||||
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':
|
||||
return {
|
||||
startDate: startOfWeek(now),
|
||||
endDate: endOfWeek(now),
|
||||
startDate: startOfWeek(now, { locale: localeOptions }),
|
||||
endDate: endOfWeek(now, { locale: localeOptions }),
|
||||
unit: 'day',
|
||||
value,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user