properly export events repeating multiple days a week

This commit is contained in:
tibbi 2017-04-16 12:08:27 +02:00
parent 5d17be541c
commit 4f136afae1
2 changed files with 39 additions and 1 deletions

View File

@ -82,6 +82,7 @@ val RRULE = "RRULE:"
val CATEGORIES = "CATEGORIES:"
val STATUS = "STATUS:"
val EXDATE = "EXDATE"
val BYDAY = "BYDAY"
val DISPLAY = "DISPLAY"
val FREQ = "FREQ"
@ -96,3 +97,11 @@ val DAILY = "DAILY"
val WEEKLY = "WEEKLY"
val MONTHLY = "MONTHLY"
val YEARLY = "YEARLY"
val MO = "MO"
val TU = "TU"
val WE = "WE"
val TH = "TH"
val FR = "FR"
val SA = "SA"
val SU = "SU"

View File

@ -64,7 +64,8 @@ class IcsExporter {
val freq = getFreq(repeatInterval)
val interval = getInterval(repeatInterval)
val repeatLimit = getRepeatLimitString(event)
val rrule = "$RRULE$FREQ=$freq;$INTERVAL=$interval$repeatLimit"
val byDay = getByDay(event)
val rrule = "$RRULE$FREQ=$freq;$INTERVAL=$interval$repeatLimit$byDay"
out.writeLn(rrule)
}
@ -97,6 +98,34 @@ class IcsExporter {
";$UNTIL=${Formatter.getDayCodeFromTS(event.repeatLimit)}"
}
private fun getByDay(event: Event): String {
return if (event.repeatInterval != WEEK) {
""
} else {
val days = getByDayString(event.repeatRule)
";$BYDAY=$days"
}
}
private fun getByDayString(rule: Int): String {
var result = ""
if (rule and MONDAY != 0)
result += "$MO,"
if (rule and TUESDAY != 0)
result += "$TU,"
if (rule and WEDNESDAY != 0)
result += "$WE,"
if (rule and THURSDAY != 0)
result += "$TH,"
if (rule and FRIDAY != 0)
result += "$FR,"
if (rule and SATURDAY != 0)
result += "$SA,"
if (rule and SUNDAY != 0)
result += "$SU,"
return result.trimEnd(',')
}
private fun fillReminders(event: Event, out: BufferedWriter) {
checkReminder(event.reminder1Minutes, out)
checkReminder(event.reminder2Minutes, out)