parse repeat limit if it was set as event occurrence count, not a date

This commit is contained in:
tibbi 2017-02-19 22:27:24 +01:00
parent 5f7623deeb
commit 4729b09004
1 changed files with 16 additions and 6 deletions

View File

@ -28,6 +28,7 @@ class IcsParser {
private val DISPLAY = "DISPLAY" private val DISPLAY = "DISPLAY"
private val FREQ = "FREQ" private val FREQ = "FREQ"
private val UNTIL = "UNTIL" private val UNTIL = "UNTIL"
private val COUNT = "COUNT"
private val INTERVAL = "INTERVAL" private val INTERVAL = "INTERVAL"
private val DAILY = "DAILY" private val DAILY = "DAILY"
@ -171,14 +172,23 @@ class IcsParser {
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("=")
if (keyValue[0] == FREQ) { val key = keyValue[0]
frequencySeconds = getFrequencySeconds(keyValue[1]) val value = keyValue[1]
} else if (keyValue[0] == INTERVAL) { if (key == FREQ) {
return frequencySeconds * keyValue[1].toInt() frequencySeconds = getFrequencySeconds(value)
} else if (keyValue[0] == UNTIL) { } else if (key == COUNT) {
curRepeatLimit = parseDateTimeValue(keyValue[1]) count = value.toInt()
} else if (key == UNTIL) {
curRepeatLimit = parseDateTimeValue(value)
} else if (key == INTERVAL) {
val interval = value.toInt()
val repeatInterval = frequencySeconds * interval
if (count > 0)
curRepeatLimit = curStart + count * repeatInterval
return repeatInterval
} }
} }
return frequencySeconds return frequencySeconds