From bf6f666d63df0c92cee9e318fa924b8c00ad5d16 Mon Sep 17 00:00:00 2001 From: Tibor Kaputa Date: Tue, 9 May 2017 14:29:53 +0200 Subject: [PATCH] fix a glitch at monthly repetition on the same day --- .../kotlin/com/simplemobiletools/calendar/models/Event.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt index b42165a06..c09bfd927 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/models/Event.kt @@ -49,6 +49,10 @@ data class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var // if an event should happen on 31st with Same Day monthly repetition, dont show it at all at months with 30 or less days private fun addMonthsWithSameDay(currStart: DateTime, original: Event): DateTime { var newDateTime = currStart.plusMonths(repeatInterval / MONTH) + if (newDateTime.dayOfMonth == currStart.dayOfMonth) { + return newDateTime + } + while (newDateTime.dayOfMonth().maximumValue < Formatter.getDateTimeFromTS(original.startTS).dayOfMonth().maximumValue) { newDateTime = newDateTime.plusMonths(repeatInterval / MONTH) newDateTime = newDateTime.withDayOfMonth(newDateTime.dayOfMonth().maximumValue)