From e8dd69dceff9ee82f49e8eb9700e6029fa2ae417 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Thu, 15 Feb 2024 21:21:26 +0600 Subject: [PATCH] UBER-1204 (#4654) Signed-off-by: Denis Bykhov --- plugins/calendar/src/utils.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/calendar/src/utils.ts b/plugins/calendar/src/utils.ts index 2a9fc9c3d6..1cfcacfd51 100644 --- a/plugins/calendar/src/utils.ts +++ b/plugins/calendar/src/utils.ts @@ -57,6 +57,8 @@ function generateDailyValues ( while (true) { if (bySetPos == null || bySetPos.includes(getSetPos(currentDate))) { const res = currentDate.getTime() + if (currentDate.getTime() > to) break + if (endDate != null && currentDate.getTime() > endDate) break if (res >= from && res <= to) { values.push(res) } @@ -65,8 +67,6 @@ function generateDailyValues ( currentDate.setDate(currentDate.getDate() + (interval ?? 1)) if (count !== undefined && i === count) break - if (endDate != null && currentDate.getTime() > endDate) break - if (currentDate.getTime() >= to) break } } @@ -90,6 +90,8 @@ function generateWeeklyValues ( const end = new Date(new Date(currentDate).setDate(currentDate.getDate() + 7)) let date = currentDate while (date < end) { + if (endDate != null && date.getTime() > endDate) return + if (date.getTime() > to) return if ((byDay == null || matchesByDay(date, byDay)) && (bySetPos == null || bySetPos.includes(getSetPos(date)))) { const res = date.getTime() if (res >= from && res <= to) { @@ -99,8 +101,6 @@ function generateWeeklyValues ( } date = new Date(date.setDate(date.getDate() + 1)) if (count !== undefined && i === count) return - if (endDate != null && date.getTime() > endDate) return - if (date.getTime() >= to) return } currentDate = new Date(next) @@ -166,6 +166,8 @@ function generateMonthlyValues ( const end = new Date(new Date(currentDate).setMonth(currentDate.getMonth() + 1)) let date = currentDate while (date < end) { + if (endDate != null && date.getTime() > endDate) return + if (date.getTime() >= to) return if ( (byDay == null || matchesByDay(date, byDay)) && (byMonthDay == null || byMonthDay.includes(new Date(currentDate).getDate())) && @@ -180,8 +182,6 @@ function generateMonthlyValues ( date = new Date(date.setDate(date.getDate() + 1)) if (count !== undefined && i === count) return - if (endDate != null && date.getTime() > endDate) return - if (date.getTime() >= to) return } currentDate = new Date(next) } @@ -203,6 +203,8 @@ function generateYearlyValues ( const end = new Date(new Date(currentDate).setFullYear(currentDate.getFullYear() + 1)) let date = currentDate while (date < end) { + if (endDate != null && date.getTime() > endDate) return + if (date.getTime() > to) return if ( (byDay == null || matchesByDay(date, byDay)) && (byMonthDay == null || byMonthDay.includes(currentDate.getDate())) && @@ -219,8 +221,6 @@ function generateYearlyValues ( } date = new Date(date.setDate(date.getDate() + 1)) if (count !== undefined && i === count) return - if (endDate != null && date.getTime() > endDate) return - if (date.getTime() >= to) return } currentDate = new Date(next) }