javaicalendarrfc5545

Problems with timezone in iCalendar file


I have this iCal file:

BEGIN:VCALENDAR
METHOD:REQUEST
PRODID:Test
VERSION:2.0
BEGIN:VTIMEZONE
TZID:TestZone
BEGIN:STANDARD
DTSTART:20130509T120000
RDATE:20130509T120000
TZOFFSETFROM:-0000
TZOFFSETTO:-0000
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID=TestZone:20130509T120000
DTEND;TZID=TestZone:20130509T130000
SUMMARY:Hi! You have set a appointment with us!
ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE:MAILTO:foo@gmail.com.br
ORGANIZER:MAILTO:foo@gmail.com
LOCATION:Test Street
DESCRIPTION:Appointment
SEQUENCE:0
PRIORITY:5
CLASS:PUBLIC
STATUS:CONFIRMED
TRANSP:OPAQUE
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:REMINDER
TRIGGER;RELATED=START:-PT00H15M00S
END:VALARM
END:VEVENT
END:VCALENDAR

But when i load it in my GMAIL it says the calendar is set to 10am - 11am

enter image description here

Why this happens if my VTIMEZONE configuration don't set any offset? And how to get the actual DTSTART and DTEND times in my calendar?


Solution

  • The RFC is here: https://www.rfc-editor.org/rfc/rfc5545

    You have to specify local time with a TZID that defines the offset.

    Example:

    DTSTART;TZID=America/New_York:19970714T133000
    

    You need to use a VTIMEZONE component in the ics file.

    BEGIN:VTIMEZONE
    TZID:America/New_York
    LAST-MODIFIED:20050809T050000Z
    BEGIN:DAYLIGHT
    DTSTART:19670430T020000
    RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=-1SU;UNTIL=19730429T070000Z
    TZOFFSETFROM:-0500
    TZOFFSETTO:-0400
    TZNAME:EDT
    END:DAYLIGHT
    BEGIN:STANDARD
    DTSTART:19671029T020000
    RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU;UNTIL=20061029T060000Z
    TZOFFSETFROM:-0400
    TZOFFSETTO:-0500
    TZNAME:EST
    END:STANDARD
    END:VTIMEZONE
    

    These examples were pulled from the RFC 5545