mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-02 03:36:50 +01:00
fill in the reminder minutes at exporting
This commit is contained in:
parent
fd7be7c738
commit
18fd08d07e
@ -26,6 +26,7 @@ val BIWEEK = 1209600
|
|||||||
val MONTH = 2592000 // exact value not taken into account, Joda is used for adding months and years
|
val MONTH = 2592000 // exact value not taken into account, Joda is used for adding months and years
|
||||||
val YEAR = 31536000
|
val YEAR = 31536000
|
||||||
|
|
||||||
|
val DAY_MINUTES = 24 * 60
|
||||||
val DAY_SECONDS = 24 * 60 * 60
|
val DAY_SECONDS = 24 * 60 * 60
|
||||||
val WEEK_SECONDS = 7 * DAY_SECONDS
|
val WEEK_SECONDS = 7 * DAY_SECONDS
|
||||||
|
|
||||||
@ -54,6 +55,8 @@ val BEGIN_CALENDAR = "BEGIN:VCALENDAR"
|
|||||||
val END_CALENDAR = "END:VCALENDAR"
|
val END_CALENDAR = "END:VCALENDAR"
|
||||||
val BEGIN_EVENT = "BEGIN:VEVENT"
|
val BEGIN_EVENT = "BEGIN:VEVENT"
|
||||||
val END_EVENT = "END:VEVENT"
|
val END_EVENT = "END:VEVENT"
|
||||||
|
val BEGIN_ALARM = "BEGIN:VALARM"
|
||||||
|
val END_ALARM = "END:VALARM"
|
||||||
val DTSTART = "DTSTART"
|
val DTSTART = "DTSTART"
|
||||||
val DTEND = "DTEND"
|
val DTEND = "DTEND"
|
||||||
val DURATION = "DURATION:"
|
val DURATION = "DURATION:"
|
||||||
|
@ -36,6 +36,7 @@ class IcsExporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fillRepeatInterval(event, out)
|
fillRepeatInterval(event, out)
|
||||||
|
fillReminders(event, out)
|
||||||
|
|
||||||
out.writeLn("$STATUS$CONFIRMED")
|
out.writeLn("$STATUS$CONFIRMED")
|
||||||
out.writeLn(END_EVENT)
|
out.writeLn(END_EVENT)
|
||||||
@ -92,4 +93,34 @@ class IcsExporter {
|
|||||||
else
|
else
|
||||||
";$UNTIL=${Formatter.getDayCodeFromTS(event.repeatLimit)}"
|
";$UNTIL=${Formatter.getDayCodeFromTS(event.repeatLimit)}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun fillReminders(event: Event, out: BufferedWriter) {
|
||||||
|
checkReminder(event.reminder1Minutes, out)
|
||||||
|
checkReminder(event.reminder2Minutes, out)
|
||||||
|
checkReminder(event.reminder3Minutes, out)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkReminder(minutes: Int, out: BufferedWriter) {
|
||||||
|
if (minutes != -1) {
|
||||||
|
out.writeLn(BEGIN_ALARM)
|
||||||
|
out.writeLn("$ACTION$DISPLAY")
|
||||||
|
out.writeLn("$TRIGGER${getReminderString(minutes)}")
|
||||||
|
out.writeLn(END_ALARM)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getReminderString(minutes: Int): String {
|
||||||
|
var days = 0
|
||||||
|
var hours = 0
|
||||||
|
var remainder = minutes
|
||||||
|
if (remainder >= DAY_MINUTES) {
|
||||||
|
days = Math.floor(((remainder / DAY_MINUTES).toDouble())).toInt()
|
||||||
|
remainder -= days * DAY_MINUTES
|
||||||
|
}
|
||||||
|
if (remainder >= 60) {
|
||||||
|
hours = Math.floor(((remainder / 60).toDouble())).toInt()
|
||||||
|
remainder -= hours * 60
|
||||||
|
}
|
||||||
|
return "-P${days}DT${hours}H${remainder}M0S"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user