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 2074ea6e2..cce4eb856 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt @@ -53,7 +53,7 @@ const val IS_CUSTOMIZING_COLORS = "is_customizing_colors" const val LOOP_REMINDERS = "loop_reminders" const val DIM_PAST_EVENTS = "dim_past_events" -// repeat_rule for monthly repetition +// repeat_rule for monthly and yearly repetition const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if yearly repetition) const val REPEAT_ORDER_WEEKDAY_USE_LAST = 2 // i.e. every last sunday. 4th if a month has 4 sundays, 5th if 5 (or last sunday in june, if yearly) const val REPEAT_LAST_DAY = 3 // i.e. every last day of the month @@ -86,6 +86,7 @@ const val STATUS = "STATUS:" const val EXDATE = "EXDATE" const val BYDAY = "BYDAY" const val BYMONTHDAY = "BYMONTHDAY" +const val BYMONTH = "BYMONTH" const val LOCATION = "LOCATION" // this tag isn't a standard ICS tag, but there's no official way of adding a category color in an ics file diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Parser.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Parser.kt index 66ac36e54..f8971a14e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Parser.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Parser.kt @@ -2,6 +2,7 @@ package com.simplemobiletools.calendar.helpers import com.simplemobiletools.calendar.extensions.isXMonthlyRepetition import com.simplemobiletools.calendar.extensions.isXWeeklyRepetition +import com.simplemobiletools.calendar.extensions.isXYearlyRepetition import com.simplemobiletools.calendar.extensions.seconds import com.simplemobiletools.calendar.models.Event import com.simplemobiletools.calendar.models.RepeatRule @@ -29,7 +30,7 @@ class Parser { if (value == WEEKLY) { val start = Formatter.getDateTimeFromTS(startTS) repeatRule = Math.pow(2.0, (start.dayOfWeek - 1).toDouble()).toInt() - } else if (value == MONTHLY) { + } else if (value == MONTHLY || value == YEARLY) { repeatRule = REPEAT_SAME_DAY } } else if (key == COUNT) { @@ -41,7 +42,7 @@ class Parser { } else if (key == BYDAY) { if (repeatInterval.isXWeeklyRepetition()) { repeatRule = handleRepeatRule(value) - } else if (repeatInterval.isXMonthlyRepetition()) { + } else if (repeatInterval.isXMonthlyRepetition() || repeatInterval.isXYearlyRepetition()) { repeatRule = if (value.startsWith("-1")) REPEAT_ORDER_WEEKDAY_USE_LAST else REPEAT_ORDER_WEEKDAY } } else if (key == BYMONTHDAY && value.toInt() == -1) {