fix(Calendar Date Issues):fixes a variety of user_locale calendar bugs

This commit is contained in:
SimonGschnell
2025-01-10 13:46:24 +01:00
parent d9375e2c8b
commit 478588aef0
4 changed files with 37 additions and 22 deletions
+7 -1
View File
@@ -89,7 +89,12 @@ export default {
}
}
});
}
},
"$p.user_locale.value"(newUserLocale){
// reset the calculation of the calendarWeek when changing user_locale
this.focusDate._clean();
this.focusDate.setLocale(newUserLocale);
},
},
emits: [
'select:day',
@@ -201,6 +206,7 @@ export default {
this.mode = allowedInitialModes[allowedInitialModes.indexOf(this.initialMode)] || allowedInitialModes.pop();
this.date.set(new Date(this.initialDate));
this.focusDate.set(this.date);
this.focusDate.setLocale(this.$p.user_locale.value);
},
mounted() {
if (this.$refs.container) {
+3 -1
View File
@@ -38,6 +38,7 @@ export default {
},
weeks() {
let firstDayOfMonth = new CalendarDate(this.year, this.month, 1);
firstDayOfMonth.setLocale(this.$p.user_locale.value);
let startDay = firstDayOfMonth.firstDayOfCalendarMonth;
let endDay = firstDayOfMonth.lastDayOfCalendarMonth;
@@ -47,7 +48,8 @@ export default {
week.days.push(new Date(startDay));
if (week.days.length == 7) {
let d = new CalendarDate(week.days[res.length ? 0 : 6]);
let d = new CalendarDate(week.days[5]);
d.setLocale(this.$p.user_locale.value);
week.no = d.w;
week.y = d.y;
res.push(week);
@@ -71,6 +71,7 @@ export default {
days() {
let tmpDate = new CalendarDate(this.year,1,1); // NOTE(chris): somewhere in the middle of the year
tmpDate.setLocale(this.$p.user_locale.value);
tmpDate.w = this.week;
let startDay = tmpDate.firstDayOfWeek;
let result = [];