Menu

Start & End dates/times incorrect when parsing iCal.

Anonymous
2015-10-06
2015-10-29
  • Anonymous

    Anonymous - 2015-10-06

    I am parsing the iCal below and get incorrect date/time values. Please advise if I should be doing something differently?

    BEGIN:VCALENDAR
    PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN
    VERSION:2.0
    METHOD:REQUEST
    BEGIN:VTIMEZONE
    TZID:Eastern Time
    BEGIN:STANDARD
    DTSTART:20131101T020000
    RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
    TZOFFSETFROM:-0400
    TZOFFSETTO:-0500
    TZNAME:Standard Time
    END:STANDARD
    BEGIN:DAYLIGHT
    DTSTART:20130301T020000
    RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
    TZOFFSETFROM:-0500
    TZOFFSETTO:-0400
    TZNAME:Daylight Savings Time
    END:DAYLIGHT
    END:VTIMEZONE
    BEGIN:VEVENT
    ATTENDEE;CN="";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:m@op.com
    ORGANIZER;CN="Trishla Sutaria":MAILTO:t@op.com
    DTSTART;TZID="Eastern Time":20150817T144202
    DTEND;TZID="Eastern Time":20150817T154202
    LOCATION:East Conference Room
    TRANSP:OPAQUE
    SEQUENCE:1439836923
    UID:9db2ab28-14a8-4773-b623-65d0e9832b5a
    DTSTAMP:20150817T184202Z
    DESCRIPTION:\nJOIN WEBEX MEETING\n
    SUMMARY:M's test meeting
    PRIORITY:5
    CLASS:PUBLIC
    END:VEVENT
    END:VCALENDAR

    When the iCal is parsed, the start and end dates change to 08/13 from 08/17 and the time is different as well. Please see the parse results below. I am simply using
    ICalendar ical = Biweekly.parse(new File("/sdcard/Download/WebEx_Meeting.ics")).first()
    VEvent event = ical.getEvents().get(0);

    2 = {java.util.LinkedHashMap$LinkedEntry@9546} "class biweekly.property.DateStart" -> " size = 1"
    key = {java.lang.Class@6553} "class biweekly.property.DateStart"
    value = {java.util.ArrayList@9560} size = 1
    0 = {biweekly.property.DateStart@9588}
    value = {biweekly.util.ICalDate@9589} "Thu Aug 13 20:04:53 EDT 2015"
    parameters = {biweekly.parameter.ICalParameters@9590} "{}"
    shadow$klass = {java.lang.Class@6553} "class biweekly.property.DateStart"
    shadow$monitor = -1847570932
    3 = {java.util.LinkedHashMap$LinkedEntry@9547} "class biweekly.property.DateEnd" -> " size = 1"
    key = {java.lang.Class@5879} "class biweekly.property.DateEnd"
    value = {java.util.ArrayList@9561} size = 1
    0 = {biweekly.property.DateEnd@9595}
    value = {biweekly.util.ICalDate@9596} "Thu Aug 13 20:19:53 EDT 2015"
    parameters = {biweekly.parameter.ICalParameters@9597} "{}"
    shadow$klass = {java.lang.Class@5879} "class biweekly.property.DateEnd"
    shadow$monitor = -1651436715

     
  • Michael Angstadt

    Hello. Sorry for the late reply.

    I was not able to reproduce the issue. When I parsed the above iCalendar object, I got the correct dates--8/17/2015 14:42 and 8/17/2015 15:42.

     
  • Anonymous

    Anonymous - 2015-10-27

    Thanks for looking at the issue. I retried it and get the correct dates now. BTW, I tried to get the timezone using the code below, but tzi returns null for the above iCal. Anything I should be doing differently? Also, any timezones/time zone representations that I should be careful with?

            ICalReader iCalReader = new ICalReader(f);
            TimezoneInfo tzi = iCalReader.getTimezoneInfo();
    

    Also, should getCreated() return DTSTAMP? And how do I get whether the event is an all day event?

     
  • Michael Angstadt

    BTW, I tried to get the timezone using the code below, but tzi returns null for the above iCal. Anything I should be doing differently?

    You must call "getTimezoneInfo()" after calling "readNext()".

    :::java
    ICalReader reader = ...
    ICalendar ical = reader.readNext();
    TimezoneInfo tzinfo = reader.getTimezoneInfo();
    

    Also, any timezones/time zone representations that I should be careful with?

    biweekly is pretty smart about timezones. If there's a particular timezone you're having trouble with, please let me know.

    Also, should getCreated() return DTSTAMP?

    The CREATED property stores the creation date of the calendar data. The DTSTAMP property, however, typically stores the time that the date that the calendar data was last updated (the LAST-MODIFIED property also stores this information). See the DateTimeStamp Javadocs for more information.

    And how do I get whether the event is an all day event?

    I'm pretty sure the best way to define an all-day even is to (1) define the start and end dates as dates (without time components) and (2) to set the end date one day ahead of the start date:

    :::java
    Date start = ...
    Calendar c = Calendar.getInstance();
    c.setTime(start);
    c.add(Calendar.DATE, 1);
    Date end = c.getTime();
    
    VEvent event = new VEvent();
    event.setDateStart(new DateStart(start, false));
    event.setDateEnd(new DateEnd(end, false));
    
     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.