mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
handle exporting and importing events repeating monthly on last day
This commit is contained in:
@@ -84,6 +84,7 @@ val CATEGORIES = "CATEGORIES:"
|
|||||||
val STATUS = "STATUS:"
|
val STATUS = "STATUS:"
|
||||||
val EXDATE = "EXDATE"
|
val EXDATE = "EXDATE"
|
||||||
val BYDAY = "BYDAY"
|
val BYDAY = "BYDAY"
|
||||||
|
val BYMONTHDAY = "BYMONTHDAY"
|
||||||
|
|
||||||
val DISPLAY = "DISPLAY"
|
val DISPLAY = "DISPLAY"
|
||||||
val FREQ = "FREQ"
|
val FREQ = "FREQ"
|
||||||
|
@@ -2,6 +2,8 @@ package com.simplemobiletools.calendar.helpers
|
|||||||
|
|
||||||
import com.simplemobiletools.calendar.activities.SimpleActivity
|
import com.simplemobiletools.calendar.activities.SimpleActivity
|
||||||
import com.simplemobiletools.calendar.extensions.dbHelper
|
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.extensions.writeLn
|
||||||
import com.simplemobiletools.calendar.helpers.IcsExporter.ExportResult.*
|
import com.simplemobiletools.calendar.helpers.IcsExporter.ExportResult.*
|
||||||
import com.simplemobiletools.calendar.models.Event
|
import com.simplemobiletools.calendar.models.Event
|
||||||
@@ -103,11 +105,17 @@ class IcsExporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getByDay(event: Event): String {
|
private fun getByDay(event: Event): String {
|
||||||
return if (event.repeatInterval == 0 || event.repeatInterval % WEEK != 0) {
|
return if (event.repeatInterval.isXWeeklyRepetition()) {
|
||||||
""
|
|
||||||
} else {
|
|
||||||
val days = getByDayString(event.repeatRule)
|
val days = getByDayString(event.repeatRule)
|
||||||
";$BYDAY=$days"
|
";$BYDAY=$days"
|
||||||
|
} else if (event.repeatInterval.isXMonthlyRepetition()) {
|
||||||
|
if (event.repeatRule == REPEAT_MONTH_LAST_DAY) {
|
||||||
|
";$BYMONTHDAY=-1"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -202,6 +202,8 @@ class IcsImporter {
|
|||||||
if (value == WEEKLY) {
|
if (value == WEEKLY) {
|
||||||
val start = Formatter.getDateTimeFromTS(curStart)
|
val start = Formatter.getDateTimeFromTS(curStart)
|
||||||
curRepeatRule = Math.pow(2.0, (start.dayOfWeek - 1).toDouble()).toInt()
|
curRepeatRule = Math.pow(2.0, (start.dayOfWeek - 1).toDouble()).toInt()
|
||||||
|
} else if (value == MONTHLY) {
|
||||||
|
curRepeatRule = REPEAT_MONTH_SAME_DAY
|
||||||
}
|
}
|
||||||
} else if (key == COUNT) {
|
} else if (key == COUNT) {
|
||||||
curRepeatLimit = -value.toInt()
|
curRepeatLimit = -value.toInt()
|
||||||
@@ -211,6 +213,8 @@ class IcsImporter {
|
|||||||
frequencySeconds *= value.toInt()
|
frequencySeconds *= value.toInt()
|
||||||
} else if (key == BYDAY) {
|
} else if (key == BYDAY) {
|
||||||
handleRepeatRule(value)
|
handleRepeatRule(value)
|
||||||
|
} else if (key == BYMONTHDAY && value.toInt() == -1) {
|
||||||
|
curRepeatRule = REPEAT_MONTH_LAST_DAY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return frequencySeconds
|
return frequencySeconds
|
||||||
|
Reference in New Issue
Block a user