handle exporting and importing events repeating every Xth day
This commit is contained in:
parent
57fb030d96
commit
bb53596b6e
|
@ -111,6 +111,12 @@ class IcsExporter {
|
|||
} else if (event.repeatInterval.isXMonthlyRepetition()) {
|
||||
if (event.repeatRule == REPEAT_MONTH_LAST_DAY) {
|
||||
";$BYMONTHDAY=-1"
|
||||
} else if (event.repeatRule == REPEAT_MONTH_EVERY_XTH_DAY) {
|
||||
val start = Formatter.getDateTimeFromTS(event.startTS)
|
||||
val dayOfMonth = start.dayOfMonth
|
||||
val order = (dayOfMonth - 1) / 7 + 1
|
||||
val day = getDayLetters(start.dayOfWeek)
|
||||
";$BYDAY=$order$day"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
@ -138,6 +144,18 @@ class IcsExporter {
|
|||
return result.trimEnd(',')
|
||||
}
|
||||
|
||||
private fun getDayLetters(dayOfWeek: Int): String {
|
||||
return when (dayOfWeek) {
|
||||
1 -> MO
|
||||
2 -> TU
|
||||
3 -> WE
|
||||
4 -> TH
|
||||
5 -> FR
|
||||
6 -> SA
|
||||
else -> SU
|
||||
}
|
||||
}
|
||||
|
||||
private fun fillReminders(event: Event, out: BufferedWriter) {
|
||||
checkReminder(event.reminder1Minutes, out)
|
||||
checkReminder(event.reminder2Minutes, out)
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.simplemobiletools.calendar.helpers
|
|||
import android.content.Context
|
||||
import com.simplemobiletools.calendar.R
|
||||
import com.simplemobiletools.calendar.extensions.dbHelper
|
||||
import com.simplemobiletools.calendar.extensions.isXMonthlyRepetition
|
||||
import com.simplemobiletools.calendar.extensions.isXWeeklyRepetition
|
||||
import com.simplemobiletools.calendar.extensions.seconds
|
||||
import com.simplemobiletools.calendar.helpers.IcsImporter.ImportResult.*
|
||||
import com.simplemobiletools.calendar.models.Event
|
||||
|
@ -212,7 +214,11 @@ class IcsImporter {
|
|||
} else if (key == INTERVAL) {
|
||||
frequencySeconds *= value.toInt()
|
||||
} else if (key == BYDAY) {
|
||||
handleRepeatRule(value)
|
||||
if (frequencySeconds.isXWeeklyRepetition()) {
|
||||
handleRepeatRule(value)
|
||||
} else if (frequencySeconds.isXMonthlyRepetition()) {
|
||||
curRepeatRule = REPEAT_MONTH_EVERY_XTH_DAY
|
||||
}
|
||||
} else if (key == BYMONTHDAY && value.toInt() == -1) {
|
||||
curRepeatRule = REPEAT_MONTH_LAST_DAY
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue