From 7055bef9d780ec0c2a9b9edce96dd3d2077ae117 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 10 Jan 2022 11:30:57 +0100 Subject: [PATCH] fix a daylight saving related glitch at importing from .ics files --- .../calendar/pro/helpers/IcsImporter.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 f9f72fc42..55e2fbc59 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 @@ -14,8 +14,9 @@ import com.simplemobiletools.calendar.pro.models.EventType import com.simplemobiletools.calendar.pro.models.Reminder import com.simplemobiletools.commons.extensions.areDigitsOnly import com.simplemobiletools.commons.extensions.showErrorToast -import java.io.File +import com.simplemobiletools.commons.helpers.HOUR_SECONDS import org.joda.time.DateTimeZone +import java.io.File class IcsImporter(val activity: SimpleActivity) { enum class ImportResult { @@ -241,6 +242,13 @@ class IcsImporter(val activity: SimpleActivity) { if (event.getIsAllDay() && curEnd > curStart) { event.endTS -= DAY + + // fix some glitches related to daylight saving shifts + if (event.startTS - event.endTS == HOUR_SECONDS.toLong()) { + event.endTS += HOUR_SECONDS + } else if (event.startTS - event.endTS == -HOUR_SECONDS.toLong()) { + event.endTS -= HOUR_SECONDS + } } if (event.importId.isEmpty()) {