fix a daylight saving related glitch at importing from .ics files

This commit is contained in:
tibbi 2022-01-10 11:30:57 +01:00
parent 2090d81be2
commit 7055bef9d7

View file

@ -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()) {