Menu

RecurrenceId date doesn't include timezone information (v0.4.1)

2015-02-24
2015-03-02
  • Nicolae Cismaru

    Nicolae Cismaru - 2015-02-24

    I'm using biweekly 0.4.1 because I need to work with recurring events. One thing I've noticed is that the date from a RECURRENCE-ID property doesn't include timezone information. Here's a test that shows this problem.

    import java.util.Calendar;
    import java.util.Date;
    
    import junit.framework.Assert;
    
    import org.junit.Test;
    
    import biweekly.Biweekly;
    import biweekly.ICalendar;
    import biweekly.component.VEvent;
    
    public class BiweeklyRecurrenceIdTest {
        @Test
        public void test() {
            System.setProperty("user.timezone", "GMT");
    
            ICalendar ical = Biweekly.parse(createCalendar()).first();
    
            for (VEvent event : ical.getEvents()) {
                if (event.getRecurrenceId() != null) {
                    //RECURRENCE-ID;TZID=America/New_York:20150119T170000
                    //5 pm new york == 10 pm gmt
                    Assert.assertEquals(new Date(2015-1900,Calendar.JANUARY,19,22,0,0), event.getRecurrenceId().getValue());
                }
            }
        }
    
        /**
         * Creates a calendar with a recurring event. One instance of the event is changed so that the calendar 
         * has a VEVENT component with a RECURRENCE-ID property.
         * 
         * The event is scheduled each week between 17:00 and 18:00.
         * On 2015/01/19 it's scheduled between 16:00 and 17:00.
         */
        private static String createCalendar() {
            String calendar =
            "BEGIN:VCALENDAR\r\n" + 
            "PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN\r\n" + 
            "VERSION:2.0\r\n" + 
    
            "BEGIN:VTIMEZONE\r\n" + 
            "TZID:America/New_York\r\n" + 
            "X-LIC-LOCATION:America/New_York\r\n" + 
            "BEGIN:DAYLIGHT\r\n" + 
            "TZOFFSETFROM:-0500\r\n" + 
            "TZOFFSETTO:-0400\r\n" + 
            "TZNAME:EDT\r\n" + 
            "DTSTART:19700308T020000\r\n" + 
            "RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3\r\n" + 
            "END:DAYLIGHT\r\n" + 
            "BEGIN:STANDARD\r\n" + 
            "TZOFFSETFROM:-0400\r\n" + 
            "TZOFFSETTO:-0500\r\n" + 
            "TZNAME:EST\r\n" + 
            "DTSTART:19701101T020000\r\n" + 
            "RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11\r\n" + 
            "END:STANDARD\r\n" + 
            "END:VTIMEZONE\r\n" +
    
            "BEGIN:VEVENT\r\n" + 
            "CREATED:20150224T081902Z\r\n" + 
            "LAST-MODIFIED:20150224T082003Z\r\n" + 
            "DTSTAMP:20150224T082003Z\r\n" + 
            "UID:0d557873-4922-44df-ba34-4defabf6f912\r\n" + 
            "SUMMARY:Test Event\r\n" + 
            "RRULE:FREQ=WEEKLY\r\n" + 
            "DTSTART;TZID=America/New_York:20150105T170000\r\n" + 
            "DTEND;TZID=America/New_York:20150105T180000\r\n" + 
            "TRANSP:OPAQUE\r\n" + 
            "X-MOZ-GENERATION:1\r\n" + 
            "END:VEVENT\r\n" + 
    
            "BEGIN:VEVENT\r\n" + 
            "CREATED:20150224T081947Z\r\n" + 
            "LAST-MODIFIED:20150224T082003Z\r\n" + 
            "DTSTAMP:20150224T082003Z\r\n" + 
            "UID:0d557873-4922-44df-ba34-4defabf6f912\r\n" + 
            "SUMMARY:Test Event\r\n" + 
            "RECURRENCE-ID;TZID=America/New_York:20150119T170000\r\n" + 
            "DTSTART;TZID=America/New_York:20150119T160000\r\n" + 
            "DTEND;TZID=America/New_York:20150119T170000\r\n" + 
            "TRANSP:OPAQUE\r\n" + 
            "SEQUENCE:1\r\n" + 
            "X-MOZ-GENERATION:1\r\n" + 
            "END:VEVENT\r\n" + 
    
            "END:VCALENDAR";
    
            return calendar;
        }
    }
    

    This problem is fixed if the following constructor is added to biweekly.property.RecurrenceId.

    public class RecurrenceId extends DateOrDateTimeProperty {
        public RecurrenceId(ICalDate startDate) {
            super(startDate);
        }
    }
    
     
  • Michael Angstadt

    Thanks for reporting this. I added the constructor to RecurrenceId. The fix will be included in the next release.

     
  • Nicolae Cismaru

    Nicolae Cismaru - 2015-03-02

    Thanks Michael!

     

Anonymous
Anonymous

Add attachments
Cancel