Fix calendar yearly events duplicates (#5874)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-06-20 21:09:56 +05:00 committed by GitHub
parent 30753b4a7a
commit 7ea0a05f59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)