[go: nahoru, domu]

Skip to content

Commit

Permalink
Fix calendar yearly events duplicates (hcengineering#5874)
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
  • Loading branch information
BykhovDenis committed Jun 20, 2024
1 parent 30753b4 commit 7ea0a05
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions plugins/calendar/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7ea0a05

Please sign in to comment.