add a couple properties to exported events

This commit is contained in:
tibbi 2017-04-03 21:41:27 +02:00
parent af377210fe
commit d5d9df7260
2 changed files with 12 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import org.joda.time.format.DateTimeFormat
object Formatter {
val DAYCODE_PATTERN = "YYYYMMdd"
val YEAR_PATTERN = "YYYY"
val TIME_PATTERN = "HHmmss"
private val DAY_PATTERN = "d"
private val DAY_OF_WEEK_PATTERN = "EEE"
private val PATTERN_TIME_12 = "hh:mm a"
@ -71,4 +72,9 @@ object Formatter {
fun getHourPattern(context: Context) = if (context.config.use24hourFormat) PATTERN_HOURS_24 else PATTERN_HOURS_12
fun getTimePattern(context: Context) = if (context.config.use24hourFormat) PATTERN_TIME_24 else PATTERN_TIME_12
fun getExportedTime(ts: Int): String {
val dateTime = getDateTimeFromTS(ts)
return "${dateTime.toString(DAYCODE_PATTERN)}T${dateTime.toString(TIME_PATTERN)}Z"
}
}

View File

@ -21,6 +21,12 @@ class IcsExporter {
for (event in events) {
out.writeLn(BEGIN_EVENT)
event.title.let { if (it.isNotEmpty()) out.writeLn("$SUMMARY$it") }
event.description.let { if (it.isNotEmpty()) out.writeLn("$DESCRIPTION$it") }
event.importId?.let { if (it.isNotEmpty()) out.writeLn("$UID$it") }
event.startTS.let { out.writeLn("$DTSTART:${Formatter.getExportedTime(it)}") }
event.endTS.let { out.writeLn("$DTEND:${Formatter.getExportedTime(it)}") }
out.writeLn(END_EVENT)
}
out.writeLn(END_CALENDAR)