add repeatable event if UNTIL is the time of last occurences start

This commit is contained in:
tibbi 2017-04-09 21:13:30 +02:00
parent c18bd90f21
commit 1957320bc8

View file

@ -387,14 +387,14 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
// get repeatable events // get repeatable events
val selection = "$COL_REPEAT_INTERVAL != 0 AND $COL_START_TS < $toTS" val selection = "$COL_REPEAT_INTERVAL != 0 AND $COL_START_TS < $toTS"
val events = getEvents(selection) val events = getEvents(selection)
for (e in events) { for (event in events) {
while (e.startTS < toTS && (e.repeatLimit == 0 || e.repeatLimit > e.endTS)) { while (event.startTS < toTS && (event.repeatLimit == 0 || event.repeatLimit >= event.startTS)) {
if (e.startTS >= fromTS) { if (event.startTS >= fromTS) {
newEvents.add(e.copy()) newEvents.add(event.copy())
} else if (getRunningEvents && (e.startTS <= fromTS && e.endTS >= toTS)) { } else if (getRunningEvents && (event.startTS <= fromTS && event.endTS >= toTS)) {
newEvents.add(e.copy()) newEvents.add(event.copy())
} }
e.addIntervalTime() event.addIntervalTime()
} }
} }