vAlarmToMin

fun vAlarmToMin(alarm: VAlarm, reference: ICalendar, allowRelEnd: Boolean): Pair<Related, Int>?

Calculates the minutes before/after an event/task a given alarm occurs.

Return

Pair of values:

  1. whether the minutes are related to the start or end (always Related.START if allowRelEnd is false)

  2. number of minutes before start/end (negative value means number of minutes after start/end)

May be null if there's not enough information to calculate the number of minutes.

Parameters

alarm

the alarm to calculate the minutes from

reference

reference VEvent or VToDo to take start/end time from (required for calculations)

allowRelEnd

true: caller accepts minutes related to the end; false: caller only accepts minutes related to the start

Android's alarm granularity is minutes. This methods calculates with milliseconds, but the result is rounded down to minutes (seconds cut off).