Search in sources :

Example 41 with ZComponent

use of com.zimbra.common.calendar.ZCalendar.ZComponent in project zm-mailbox by Zimbra.

the class TestCalDav method testFuzzyTimeZoneMatchGMT06.

@Test
public void testFuzzyTimeZoneMatchGMT06() throws Exception {
    try (ByteArrayInputStream bais = new ByteArrayInputStream(VtimeZoneGMT_0600_0500.getBytes())) {
        ZVCalendar tzcal = ZCalendar.ZCalendarBuilder.build(bais, MimeConstants.P_CHARSET_UTF8);
        assertNotNull("tzcal", tzcal);
        ZComponent tzcomp = tzcal.getComponent(ICalTok.VTIMEZONE);
        assertNotNull("tzcomp", tzcomp);
        ICalTimeZone tz = ICalTimeZone.fromVTimeZone(tzcomp, false, /* skipLookup */
        ICalTimeZone.TZID_NAME_ASSIGNMENT_BEHAVIOR.ALWAYS_KEEP);
        ICalTimeZone matchtz = ICalTimeZone.lookupMatchingWellKnownTZ(tz);
        assertEquals("ID of Timezone which fuzzy matches GMT=06.00/-05.00", "America/Chicago", matchtz.getID());
    }
}
Also used : ZComponent(com.zimbra.common.calendar.ZCalendar.ZComponent) ZVCalendar(com.zimbra.common.calendar.ZCalendar.ZVCalendar) ByteArrayInputStream(java.io.ByteArrayInputStream) ICalTimeZone(com.zimbra.common.calendar.ICalTimeZone) Test(org.junit.Test)

Aggregations

ZComponent (com.zimbra.common.calendar.ZCalendar.ZComponent)41 ZProperty (com.zimbra.common.calendar.ZCalendar.ZProperty)22 ZVCalendar (com.zimbra.common.calendar.ZCalendar.ZVCalendar)19 ICalTimeZone (com.zimbra.common.calendar.ICalTimeZone)16 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)10 ICalTok (com.zimbra.common.calendar.ZCalendar.ICalTok)9 ZParameter (com.zimbra.common.calendar.ZCalendar.ZParameter)8 ParsedDateTime (com.zimbra.common.calendar.ParsedDateTime)7 Account (com.zimbra.cs.account.Account)7 Invite (com.zimbra.cs.mailbox.calendar.Invite)7 ByteArrayInputStream (java.io.ByteArrayInputStream)7 IOException (java.io.IOException)7 InputStream (java.io.InputStream)7 TimeZoneMap (com.zimbra.common.calendar.TimeZoneMap)5 ServiceException (com.zimbra.common.service.ServiceException)4 MessagingException (javax.mail.MessagingException)4 MimeMessage (javax.mail.internet.MimeMessage)4 ParsedMessage (com.zimbra.cs.mime.ParsedMessage)3 CalendarPartInfo (com.zimbra.cs.mime.ParsedMessage.CalendarPartInfo)3