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.

Fix calendar bug, closes #892

Mike Cao066c0cf5ba76
diff --git a/components/common/Calendar.js b/components/common/Calendar.js
index 7aea34c3d..288cb1846 100644
--- a/components/common/Calendar.js
+++ b/components/common/Calendar.js
@@ -106,12 +106,19 @@ export default function Calendar({ date, minDate, maxDate, onChange }) {
}
const DaySelector = ({ date, minDate, maxDate, locale, onSelect }) => {
- const startWeek = startOfWeek(date, { locale: getDateLocale(locale) });
- const startMonth = startOfMonth(date, { locale: getDateLocale(locale) });
- const startDay = subDays(startMonth, startMonth.getDay());
+ const dateLocale = getDateLocale(locale);
+ const weekStartsOn = dateLocale?.options?.weekStartsOn || 0;
+ const startWeek = startOfWeek(date, {
+ locale: dateLocale,
+ weekStartsOn,
+ });
+ const startMonth = startOfMonth(date);
+ const startDay = subDays(startMonth, startMonth.getDay() - weekStartsOn);
const month = date.getMonth();
const year = date.getFullYear();
+ console.log({ dateLocale, startDay, startWeek, startMonth, month, year });
+
const daysOfWeek = [];
for (let i = 0; i < 7; i++) {
daysOfWeek.push(addDays(startWeek, i));