properly handle the "count" field at importing events

This commit is contained in:
tibbi 2017-04-23 22:38:54 +02:00
parent b02f055d6a
commit 243e28cb1e
1 changed files with 2 additions and 11 deletions

View File

@ -191,7 +191,6 @@ class IcsImporter {
private fun parseRepeatInterval(fullString: String): Int { private fun parseRepeatInterval(fullString: String): Int {
val parts = fullString.split(";") val parts = fullString.split(";")
var frequencySeconds = 0 var frequencySeconds = 0
var count = 0
for (part in parts) { for (part in parts) {
val keyValue = part.split("=") val keyValue = part.split("=")
val key = keyValue[0] val key = keyValue[0]
@ -203,19 +202,11 @@ class IcsImporter {
curRepeatRule = Math.pow(2.0, (start.dayOfWeek - 1).toDouble()).toInt() curRepeatRule = Math.pow(2.0, (start.dayOfWeek - 1).toDouble()).toInt()
} }
} else if (key == COUNT) { } else if (key == COUNT) {
count = value.toInt() - 1 curRepeatLimit = -value.toInt()
if (frequencySeconds != 0) {
curRepeatLimit = curStart + count * frequencySeconds
}
} else if (key == UNTIL) { } else if (key == UNTIL) {
curRepeatLimit = parseDateTimeValue(value) curRepeatLimit = parseDateTimeValue(value)
} else if (key == INTERVAL) { } else if (key == INTERVAL) {
val interval = value.toInt() frequencySeconds *= value.toInt()
val repeatInterval = frequencySeconds * interval
if (count > 0) {
curRepeatLimit = curStart + count * repeatInterval
frequencySeconds *= interval
}
} else if (key == BYDAY) { } else if (key == BYDAY) {
handleRepeatRule(value) handleRepeatRule(value)
} }