diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt index 078dda6a5..287a437aa 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt @@ -84,6 +84,7 @@ val CATEGORIES = "CATEGORIES:" val STATUS = "STATUS:" val EXDATE = "EXDATE" val BYDAY = "BYDAY" +val BYMONTHDAY = "BYMONTHDAY" val DISPLAY = "DISPLAY" val FREQ = "FREQ" diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt index d84d2a60d..0a397a3c3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsExporter.kt @@ -2,6 +2,8 @@ package com.simplemobiletools.calendar.helpers import com.simplemobiletools.calendar.activities.SimpleActivity import com.simplemobiletools.calendar.extensions.dbHelper +import com.simplemobiletools.calendar.extensions.isXMonthlyRepetition +import com.simplemobiletools.calendar.extensions.isXWeeklyRepetition import com.simplemobiletools.calendar.extensions.writeLn import com.simplemobiletools.calendar.helpers.IcsExporter.ExportResult.* import com.simplemobiletools.calendar.models.Event @@ -103,11 +105,17 @@ class IcsExporter { } private fun getByDay(event: Event): String { - return if (event.repeatInterval == 0 || event.repeatInterval % WEEK != 0) { - "" - } else { + return if (event.repeatInterval.isXWeeklyRepetition()) { val days = getByDayString(event.repeatRule) ";$BYDAY=$days" + } else if (event.repeatInterval.isXMonthlyRepetition()) { + if (event.repeatRule == REPEAT_MONTH_LAST_DAY) { + ";$BYMONTHDAY=-1" + } else { + "" + } + } else { + "" } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt index 924333244..b3714cf23 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/IcsImporter.kt @@ -202,6 +202,8 @@ class IcsImporter { if (value == WEEKLY) { val start = Formatter.getDateTimeFromTS(curStart) curRepeatRule = Math.pow(2.0, (start.dayOfWeek - 1).toDouble()).toInt() + } else if (value == MONTHLY) { + curRepeatRule = REPEAT_MONTH_SAME_DAY } } else if (key == COUNT) { curRepeatLimit = -value.toInt() @@ -211,6 +213,8 @@ class IcsImporter { frequencySeconds *= value.toInt() } else if (key == BYDAY) { handleRepeatRule(value) + } else if (key == BYMONTHDAY && value.toInt() == -1) { + curRepeatRule = REPEAT_MONTH_LAST_DAY } } return frequencySeconds