Fix setting end date

This commit is contained in:
Phillip Thelen
2024-05-07 15:17:22 +02:00
parent fbce5aae32
commit 0089506165
2 changed files with 71 additions and 4 deletions

View File

@@ -873,21 +873,28 @@ function makeMatcherClass (date) {
function makeEndDate (checkedDate, matcher) {
let end = moment(checkedDate);
end.date(TYPE_SCHEDULE[matcher.type]);
end.hour(0);
end.minute(0);
end.second(0);
if (matcher.endMonth !== undefined) {
end.month(matcher.endMonth);
} else if (end.date() <= checkedDate) {
} else if (end.date() <= checkedDate.getDate()) {
end = moment(end).add(1, 'months');
}
return end.toDate();
}
export function clearCachedMatchers () {
cacheDate = null;
cachedScheduleMatchers = null;
}
export function getAllScheduleMatchingGroups (date) {
const checkedDate = date || new Date();
if (cacheDate !== null && (getDay(checkedDate) !== getDay(cacheDate)
|| getMonth(checkedDate) !== getMonth(cacheDate))) {
// Clear cached matchers, since they are old
cacheDate = null;
cachedScheduleMatchers = null;
clearCachedMatchers();
}
if (!cachedScheduleMatchers) {
// No matchers exist, make new ones