properly handle exporting and importing during day reminders

This commit is contained in:
tibbi 2021-02-13 21:52:54 +01:00
parent 2ff02baeff
commit b85b4e3acf
3 changed files with 10 additions and 2 deletions

View File

@ -95,7 +95,9 @@ class IcsExporter {
writeLn("$ATTENDEE$MAILTO$attendee")
}
}
writeLn("$TRIGGER-${Parser().getDurationCode(reminder.minutes.toLong())}")
val sign = if (reminder.minutes < -1) "" else "-"
writeLn("$TRIGGER$sign${Parser().getDurationCode(Math.abs(reminder.minutes.toLong()))}")
writeLn(END_ALARM)
}
}

View File

@ -113,7 +113,11 @@ class IcsImporter(val activity: SimpleActivity) {
curReminderTriggerAction = if (action == DISPLAY) REMINDER_NOTIFICATION else REMINDER_EMAIL
}
} else if (line.startsWith(TRIGGER)) {
curReminderTriggerMinutes = Parser().parseDurationSeconds(line.substring(TRIGGER.length)) / 60
val value = line.substring(TRIGGER.length)
curReminderTriggerMinutes = Parser().parseDurationSeconds(value) / 60
if (!value.startsWith("-")) {
curReminderTriggerMinutes *= -1
}
} else if (line.startsWith(CATEGORY_COLOR)) {
val color = line.substring(CATEGORY_COLOR.length)
if (color.trimStart('-').areDigitsOnly()) {

View File

@ -230,10 +230,12 @@ class Parser {
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"
}
}