From 7ea0a05f5931e25ba72391c32e3feeca6ca9c79c Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Thu, 20 Jun 2024 21:09:56 +0500 Subject: [PATCH] Fix calendar yearly events duplicates (#5874) Signed-off-by: Denis Bykhov --- plugins/calendar/src/utils.ts | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/plugins/calendar/src/utils.ts b/plugins/calendar/src/utils.ts index 1cfcacfd51..aa45f3bfaf 100644 --- a/plugins/calendar/src/utils.ts +++ b/plugins/calendar/src/utils.ts @@ -206,20 +206,36 @@ function generateYearlyValues ( if (endDate != null && date.getTime() > endDate) return if (date.getTime() > to) return if ( - (byDay == null || matchesByDay(date, byDay)) && - (byMonthDay == null || byMonthDay.includes(currentDate.getDate())) && - (byYearDay == null || byYearDay.includes(getYearDay(currentDate))) && - (byWeekNo == null || byWeekNo.includes(getWeekNumber(currentDate))) && - (byMonth == null || byMonth.includes(currentDate.getMonth())) && - (bySetPos == null || bySetPos.includes(getSetPos(currentDate))) + byDay == null && + byMonthDay == null && + byYearDay == null && + byWeekNo == null && + byMonth == null && + bySetPos == null ) { + date = new Date(next) const res = currentDate.getTime() if (res >= from && res <= to) { values.push(res) } i++ + } else { + if ( + (byDay == null || matchesByDay(date, byDay)) && + (byMonthDay == null || byMonthDay.includes(currentDate.getDate())) && + (byYearDay == null || byYearDay.includes(getYearDay(currentDate))) && + (byWeekNo == null || byWeekNo.includes(getWeekNumber(currentDate))) && + (byMonth == null || byMonth.includes(currentDate.getMonth())) && + (bySetPos == null || bySetPos.includes(getSetPos(currentDate))) + ) { + const res = currentDate.getTime() + if (res >= from && res <= to) { + values.push(res) + } + i++ + } + date = new Date(date.setDate(date.getDate() + 1)) } - date = new Date(date.setDate(date.getDate() + 1)) if (count !== undefined && i === count) return } currentDate = new Date(next)