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

Unverified Commit e8807854 authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Handle case that time zone is known in Android, but not in ical4j

parent 2afb4f46
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
package at.bitfire.ical4android

import net.fortuna.ical4j.model.DefaultTimeZoneRegistryFactory
import net.fortuna.ical4j.model.TimeZone
import net.fortuna.ical4j.model.TimeZoneRegistry
import org.junit.Assert.*
import org.junit.Assume
@@ -41,6 +42,18 @@ class AndroidCompatTimeZoneRegistryTest {
        )
    }

    @Test
    fun getTimeZone_Existing_ButNotInIcal4j() {
        val reg = AndroidCompatTimeZoneRegistry(object: TimeZoneRegistry {
            override fun register(timezone: TimeZone?) = throw NotImplementedError()
            override fun register(timezone: TimeZone?, update: Boolean) = throw NotImplementedError()
            override fun clear() = throw NotImplementedError()
            override fun getTimeZone(id: String?) = null

        })
        assertNull(reg.getTimeZone("Europe/Berlin"))
    }

    @Test
    fun getTimeZone_Existing_Kiev() {
        Assume.assumeFalse(systemKnowsKyiv)
+2 −2
Original line number Diff line number Diff line
@@ -51,8 +51,8 @@ class AndroidCompatTimeZoneRegistry(
           Example: getTimeZone("Europe/Kiev") returns a TimeZone with TZID:Europe/Kyiv since ical4j/3.2.5,
           but most Android devices don't now Europe/Kyiv yet.
           */
        val tz = base.getTimeZone(id)
        if (tz.id != androidTzId) {
        val tz: TimeZone? = base.getTimeZone(id)
        if (tz != null && tz.id != androidTzId) {
            Ical4Android.log.warning("Using Android TZID $androidTzId instead of ical4j ${tz.id}")

            // create a copy of the VTIMEZONE so that we don't modify the original registry values (which are not immutable)