From 7d9b55f064cc2526eb3b0d717680dbecd37253f0 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 21 Feb 2018 14:09:29 +0100 Subject: [PATCH] fix #374, properly import CalDAV all-day events --- .../com/simplemobiletools/calendar/helpers/Formatter.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Formatter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Formatter.kt index 65533fdf2..ef2389d3f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Formatter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Formatter.kt @@ -78,6 +78,8 @@ object Formatter { fun getDateTimeFromTS(ts: Int) = DateTime(ts * 1000L, DateTimeZone.getDefault()) + fun getUTCDateTimeFromTS(ts: Int) = DateTime(ts * 1000L, DateTimeZone.UTC) + // use manually translated month names, as DateFormat and Joda have issues with a lot of languages fun getMonthName(context: Context, id: Int) = context.resources.getStringArray(R.array.months)[id - 1] @@ -94,11 +96,12 @@ object Formatter { fun getDayCodeFromTS(ts: Int): String { val daycode = getDateTimeFromTS(ts).toString(DAYCODE_PATTERN) - return if (daycode.isNotEmpty()) + return if (daycode.isNotEmpty()) { daycode - else + } else { "0" + } } - fun getShiftedImportTimestamp(ts: Int) = getDateTimeFromTS(ts).withTime(5, 0, 0, 0).seconds() + fun getShiftedImportTimestamp(ts: Int) = getUTCDateTimeFromTS(ts).withTime(13, 0, 0, 0).withZoneRetainFields(DateTimeZone.getDefault()).seconds() }