shorten a parser code
This commit is contained in:
parent
2c535015ba
commit
63d70afae0
|
@ -126,25 +126,23 @@ class Parser {
|
||||||
else -> ";$UNTIL=${Formatter.getDayCodeFromTS(event.repeatLimit)}"
|
else -> ";$UNTIL=${Formatter.getDayCodeFromTS(event.repeatLimit)}"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getByDay(event: Event): String {
|
private fun getByDay(event: Event) = when {
|
||||||
return if (event.repeatInterval.isXWeeklyRepetition()) {
|
event.repeatInterval.isXWeeklyRepetition() -> {
|
||||||
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) {
|
event.repeatInterval.isXMonthlyRepetition() -> when {
|
||||||
";$BYMONTHDAY=-1"
|
event.repeatRule == REPEAT_MONTH_LAST_DAY -> ";$BYMONTHDAY=-1"
|
||||||
} else if (event.repeatRule == REPEAT_MONTH_EVERY_XTH_DAY) {
|
event.repeatRule == REPEAT_MONTH_EVERY_XTH_DAY -> {
|
||||||
val start = Formatter.getDateTimeFromTS(event.startTS)
|
val start = Formatter.getDateTimeFromTS(event.startTS)
|
||||||
val dayOfMonth = start.dayOfMonth
|
val dayOfMonth = start.dayOfMonth
|
||||||
val order = (dayOfMonth - 1) / 7 + 1
|
val order = (dayOfMonth - 1) / 7 + 1
|
||||||
val day = getDayLetters(start.dayOfWeek)
|
val day = getDayLetters(start.dayOfWeek)
|
||||||
";$BYDAY=$order$day"
|
";$BYDAY=$order$day"
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
}
|
||||||
} else {
|
else -> ""
|
||||||
""
|
|
||||||
}
|
}
|
||||||
|
else -> ""
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getByDayString(rule: Int): String {
|
private fun getByDayString(rule: Int): String {
|
||||||
|
|
Loading…
Reference in New Issue