简体   繁体   中英

Bug creating recurring events in daylight savings time with Google Calendar API?

So I'm making a small App Engine application through python which reads a timetable from a file and puts it into your Google Calender. All times/dates in the timetable are independent of DST so I need to put in events in the same manner. This is complicated by the fact that all the events are recurring weekly over multiple DST periods.

I am using Calender API V3.

I start by creating my own Calender for this.

calander = {
    'summary': 'Calender Name,
    'location': 'Somewhere in Ireland',
    'timeZone': 'GMT',
}

Then I populate it with many different recurring events

event = {
    'summary': 'CS101',
    'description': 'Intro to Comp Sci',
    'location': 'Bla bla bla',
    'start': {
        'dateTime': '2012-10-03T10:00:00.000-00:00',
        'timeZone': 'GMT'
    },
    'end': {
        'dateTime': '2012-10-03T11:00:00.000-00:00',
        'timeZone': 'GMT'
    },
    'recurrence': [
        'RRULE:FREQ=WEEKLY;UNTIL=20121231',
    ],
}

In my actual program of course, all of these strings are being generated dynamically, but i have no problems here.

The problem is that any event occurring during the summertime DST period is automatically put 1 hour behind the time I am giving it. I am sure this is a bug because I am setting the timezone to GMT for the events and calender, but GMT does not observe daylight savings. Nothing should be done to the times I feed in.

For instance, the timetable says an event lasts from 10AM to 11AM every monday from September 1st to December 31st. If this information is fed into the calender, all events before October 28th (the European fall back date) will one hour behind the timetable's time. All times outside of the summertime period are good.

If I tell the calender that an event starts at 10AM, I don't want it to adjust for DST. How can this be avoided?

Can it be that you have a timezone defined in the start.dateTime and end.dateTime as well? I looks like the timeZone field is not fully recognized if this is done. Try changing your dates from "2012-09-26T10:00:00.000-00:00" to just "2012-09-26T10:00:00.000" [ API->start.dateTime ]

As GMT is without DST, if you put a calendar event as the one you specified, starting at 10:00 GMT, when looking at the calendar view with your local time set to "Europe/Dublin" these events will start at 11:00 as summer time is +1.

I'm not sure what you mean with "independent" of timezone, but:

1) If you want a recurring event that start at 10:00 Irish time weekly until december (as shown on your wall clock), try this:

{
  "start": {
    "dateTime": "2012-09-26T10:00:00.000",
    "timeZone": "Europe/Dublin"
  },
  "end": {
    "dateTime": "2012-09-26T11:00:00.000",
    "timeZone": "Europe/Dublin"
  },
  "summary": "CS101 Dublin",
  "description": "Intro to Comp Sci",
  "location": "Bla bla bla",
  "recurrence": [
    "RRULE:FREQ=WEEKLY;UNTIL=20121131"
  ]
}

2) If you in fact want the event to start at 10:00 GMT weekly until december (as shown on a clock that is always set to winter time in Ireland), try this:

{
  "start": {
    "dateTime": "2012-09-26T10:00:00.000",
    "timeZone": "GMT"
  },
  "end": {
    "dateTime": "2012-09-26T11:00:00.000",
    "timeZone": "GMT"
  },
  "summary": "CS101 GMT",
  "description": "Intro to Comp Sci",
  "location": "Bla bla bla",
  "recurrence": [
    "RRULE:FREQ=WEEKLY;UNTIL=20121131"
  ]
}

This will create an event that, when shown in a calendar UI with a timezone set to "Europe/Dublin" is at 11:00 until 2012-10-31, when it will start at 10:00. You can try to switch between different time zone displays in the Calendar UI on flower button->settings->your timezone.

But my guess would be that you want (1) here, as it sounds like a CS course that would start with a time specified in local time.

Btw, when trying things out if find the API explorer pretty handy: https://developers.google.com/apis-explorer/#s/calendar/v3/

GMT is not sensible to Daylight Saving Time. You should use local time (in the case of Ireland - IST). Explanation. Different countries have different dates to start and end DST.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM