Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be6d515d authored by Ricki Hirner's avatar Ricki Hirner
Browse files

isAllDay: check for null

parent 605b9045
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ import net.fortuna.ical4j.data.CalendarOutputter
import net.fortuna.ical4j.data.ParserException
import net.fortuna.ical4j.model.*
import net.fortuna.ical4j.model.Calendar
import net.fortuna.ical4j.model.Date
import net.fortuna.ical4j.model.TimeZone
import net.fortuna.ical4j.model.component.VAlarm
import net.fortuna.ical4j.model.component.VEvent
@@ -303,6 +304,11 @@ class Event: ICalendar() {

    // helpers

    fun isAllDay() = !isDateTime(dtStart)
    /**
     * Determines whether this Event is an all-day event.
     *
     * @return *true* if [dtStart] is a DATE value; *false* otherwise ([dtStart] is a DATETIME value or *null*)
     */
    fun isAllDay() = dtStart != null && !isDateTime(dtStart)

}
+7 −0
Original line number Diff line number Diff line
@@ -79,6 +79,13 @@ class EventTest {
        assertTrue("Event 2 Exception 2" == e.exceptions.first.summary || "Event 2 Exception 2" == e.exceptions[1].summary)
    }

    @Test
    fun testIsAllDay() {
        assertFalse(Event().isAllDay())
        assertTrue(Event().apply { dtStart = DtStart(Date("20190101")) }.isAllDay())
        assertFalse(Event().apply { dtStart = DtStart(DateTime("20190101T010100")) }.isAllDay())
    }

    @Test
    fun testParse() {
        val event = parseCalendar("utf8.ics").first()