Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

feature(lib): locale option for getDateRange

Alexander Kleineb1029bfc8ab
diff --git a/lib/date.js b/lib/date.js
index e166563b7..06aaac13a 100644
--- a/lib/date.js
+++ b/lib/date.js
@@ -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,
};