From 729a632cf35f6115b5b45ddb4e7a335fd06cd873 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 6 Sep 2018 12:03:34 +0200 Subject: [PATCH] fix #599, properly determing if all-day events are running, or not --- .../calendar/helpers/DBHelper.kt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt index dbd1da785..1dd371855 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/DBHelper.kt @@ -939,7 +939,12 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont repeatRule = REPEAT_SAME_DAY } - val isPastEvent = endTS < getNowSeconds() + val endTSToCheck = if (startTS < getNowSeconds() && flags and FLAG_ALL_DAY != 0) { + Formatter.getDayEndTS(Formatter.getDayCodeFromTS(endTS)) + } else { + endTS + } + val isPastEvent = endTSToCheck < getNowSeconds() val event = Event(id, startTS, endTS, title, description, reminder1Minutes, reminder2Minutes, reminder3Minutes, repeatInterval, importId, flags, repeatLimit, repeatRule, eventType, ignoreEventOccurrences, offset, isDstIncluded, @@ -1070,5 +1075,12 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont } } - private fun getIsPastEvent(event: Event) = event.endTS < getNowSeconds() + private fun getIsPastEvent(event: Event): Boolean { + val endTSToCheck = if (event.startTS < getNowSeconds() && event.getIsAllDay()) { + Formatter.getDayEndTS(Formatter.getDayCodeFromTS(event.endTS)) + } else { + event.endTS + } + return endTSToCheck < getNowSeconds() + } }