fix #1258, properly handle importing events, if exdates are split by line

This commit is contained in:
tibbi 2021-02-23 15:12:24 +01:00
parent c8fae6c688
commit c2b31a8de4
1 changed files with 19 additions and 11 deletions

View File

@ -134,7 +134,13 @@ class IcsImporter(val activity: SimpleActivity) {
value = value.substring(0, value.length - 1)
}
if (value.contains(",")) {
value.split(",").forEach { exdate ->
curRepeatExceptions.add(Formatter.getDayCodeFromTS(getTimestamp(exdate)))
}
} else {
curRepeatExceptions.add(Formatter.getDayCodeFromTS(getTimestamp(value)))
}
} else if (line.startsWith(LOCATION)) {
curLocation = getLocation(line.substring(LOCATION.length).replace("\\,", ","))
if (curLocation.trim().isEmpty()) {
@ -247,7 +253,8 @@ class IcsImporter(val activity: SimpleActivity) {
private fun getTimestamp(fullString: String): Long {
return try {
if (fullString.startsWith(';')) {
when {
fullString.startsWith(';') -> {
val value = fullString.substring(fullString.lastIndexOf(':') + 1).replace(" ", "")
if (value.isEmpty()) {
return 0
@ -256,8 +263,9 @@ class IcsImporter(val activity: SimpleActivity) {
}
Parser().parseDateTimeValue(value)
} else {
Parser().parseDateTimeValue(fullString.substring(1))
}
fullString.startsWith(":") -> Parser().parseDateTimeValue(fullString.substring(1))
else -> Parser().parseDateTimeValue(fullString)
}
} catch (e: Exception) {
activity.showErrorToast(e)