mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-26 09:04:28 +00:00
fix jumping into march 01 from january 29
This commit is contained in:
@@ -26,7 +26,7 @@ export default {
|
|||||||
this.syncOnNextChange = false;
|
this.syncOnNextChange = false;
|
||||||
this.focusDate.set(this.date);
|
this.focusDate.set(this.date);
|
||||||
} else {
|
} else {
|
||||||
this.focusDate.m += dir;
|
this.focusDate.moveMonthInDirection(dir)
|
||||||
}
|
}
|
||||||
this.$emit('change:range', {
|
this.$emit('change:range', {
|
||||||
start: new Date(this.focusDate.y, this.focusDate.m, 1),
|
start: new Date(this.focusDate.y, this.focusDate.m, 1),
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import {user_locale} from "../plugin/Phrasen.js";
|
import {user_locale} from "../plugin/Phrasen.js";
|
||||||
import CalendarDates from "./CalendarDates.js";
|
import CalendarDates from "./CalendarDates.js";
|
||||||
|
|
||||||
|
const monthDayRanges = []
|
||||||
|
for(let i = 1; i < 13; i++) {
|
||||||
|
monthDayRanges.push(new Date(1995, i, 0).getDate())
|
||||||
|
}
|
||||||
|
|
||||||
class CalendarDate {
|
class CalendarDate {
|
||||||
constructor(y, m, d) {
|
constructor(y, m, d) {
|
||||||
this.weekStart = CalendarDate.getWeekStart();
|
this.weekStart = CalendarDate.getWeekStart();
|
||||||
@@ -210,6 +215,15 @@ class CalendarDate {
|
|||||||
cleanup(){
|
cleanup(){
|
||||||
if(this.watchLocale && this.watchLocale.stop) this.watchLocale.stop(); // TODO: ?
|
if(this.watchLocale && this.watchLocale.stop) this.watchLocale.stop(); // TODO: ?
|
||||||
}
|
}
|
||||||
|
moveMonthInDirection (dir) {
|
||||||
|
// avoid setting date in wrong month if we try to create a date which does not exist like 30th of february
|
||||||
|
const newM = this.m + dir
|
||||||
|
const maxDaysTarget = monthDayRanges[newM]
|
||||||
|
|
||||||
|
if (this.d > maxDaysTarget) this.d = maxDaysTarget
|
||||||
|
|
||||||
|
this.m = newM // calls _clean which sets a new Date
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the weekday number (Date.getDay()) on which the week starts depending on the locale.
|
* Returns the weekday number (Date.getDay()) on which the week starts depending on the locale.
|
||||||
|
|||||||
Reference in New Issue
Block a user