From d69326d527e736c4d3fabfc35d9f49c1ec42f685 Mon Sep 17 00:00:00 2001 From: ilkerulusoy Date: Thu, 5 Oct 2023 00:52:10 +0300 Subject: [PATCH] ISSUE-2222 the parse error fixed due to the order of items. --- .../calendar/pro/helpers/IcsImporter.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/IcsImporter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/IcsImporter.kt index e119cf0e0..0bf63e0fb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/IcsImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/IcsImporter.kt @@ -26,6 +26,7 @@ class IcsImporter(val activity: SimpleActivity) { private var curStart = -1L private var curEnd = -1L + private var duration = 0 private var curTitle = "" private var curLocation = "" private var curDescription = "" @@ -105,11 +106,17 @@ class IcsImporter(val activity: SimpleActivity) { parseRepeatRule() } } + + // if duration is come before DTSTART, DTEND must re-calculate. + if (duration != 0) { + curEnd = curStart + duration + } } else if (line.startsWith(DTEND)) { curEnd = getTimestamp(line.substring(DTEND.length)) } else if (line.startsWith(DURATION)) { - val duration = line.substring(DURATION.length) - curEnd = curStart + Parser().parseDurationSeconds(duration) + val durationString = line.substring(DURATION.length) + this.duration = Parser().parseDurationSeconds(durationString) + curEnd = curStart + duration } else if (line.startsWith(SUMMARY) && !isNotificationDescription) { curTitle = line.substring(SUMMARY.length) curTitle = getTitle(curTitle).replace("\\n", "\n").replace("\\,", ",")