ical4android icon indicating copy to clipboard operation
ical4android copied to clipboard

AndroidCompatTimeZoneRegistry logs inappropriate warning when constructing Europe/Copenhagen from Europe/Berlin

Open rfc2822 opened this issue 1 year ago • 2 comments

When an event has TZID:Europe/Copenhagen, AndroidCompatTimeZoneRegistry uses Europe/Berlin instead of Europe/Copenhagen (and displays a warning about this in the logs). Since both Europe/Berlin and Europe/Copenhagen are present in Android, this shouldn't happen.

The time zone has the same definition, so it's not a big problem, but it's still not working as intended.

rfc2822 avatar Aug 08 '24 12:08 rfc2822

I've ran this test

@Test
fun getTimeZone_Existing_Copenhagen() {
    val tz = registry.getTimeZone("Europe/Copenhagen")
    assertEquals("Europe/Copenhagen", tz?.id)
    assertEquals("Europe/Copenhagen", tz?.vTimeZone?.timeZoneId?.value)
}

Is this correct? Am I misunderstanding anything?

ArnyminerZ avatar Aug 09 '24 17:08 ArnyminerZ

Is this correct?

Yes.

I think the problem is primarily the logging. Your tests works, but it prints

08-03 03:05:52.235  5858  5877 W dCompatTimeZoneRegistry: Using Android TZID Europe/Copenhagen instead of ical4j Europe/Berlin

This warning (!) is highly irritating and I thought something was wrong when I saw it in some unrelated context.

If you have a look at the generated VTIMEZONE, the TZID is correct, but the body still contains references to Berlin:

@Test
    fun getTimeZone_Copenhagen() {
        val tz = registry.getTimeZone("Europe/Copenhagen")!!
        System.out.println(tz.vTimeZone)
        assertEquals(
            "Europe/Copenhagen",
            tz.id
        )
    }

// succeeds, prints

started: getTimeZone_Copenhagen(at.bitfire.ical4android.AndroidCompatTimeZoneRegistryTest)
Using Android TZID Europe/Copenhagen instead of ical4j Europe/Berlin
BEGIN:VTIMEZONE
LAST-MODIFIED:20240422T053450Z
TZURL:https://www.tzurl.org/zoneinfo/Europe/Berlin
X-LIC-LOCATION:Europe/Berlin
X-PROLEPTIC-TZNAME:LMT
TZID:Europe/Copenhagen
…
finished: getTimeZone_Copenhagen(at.bitfire.ical4android.AndroidCompatTimeZoneRegistryTest)

So it seems to work as expected, but

  • the log message shouldn't be a warning, but at debug info level and have less alerting wording: "Using ical4j timezone ${tz.id} data to construct Android timezone $androidTzId" or something like that,
  • Guess we could drop the TZURL etc. properties so that there's no reference to Berlin in the Copenhagen timezone. Although it's correct because it's an alias, it's confusing.

rfc2822 avatar Aug 12 '24 10:08 rfc2822