0

I'm trying to create a recurrence rule with the Google Calendar Api.

 [JAVASCRIPT - Google Client Library]
 var req = gapi.client.calendar.events.insert({
  [...],
  "recurrence": [
    "RRULE:FREQ=WEEKLY;UNTIL="+date.toISOString()
  ],
  [...]
 });
 req.execute();

The code above return 400 Bad request, because the recurrence rule is not correctly formatted.

I don't understand how to create a correct date format for the UNTIL field.

I've tried to use a date object and use the ISO conversion but it doesn't work either.

Anyway a single creation for the event works correctly and also a repeat with a COUNT field.

FILE ON GITHUB

rpasianotto
  • 1,383
  • 1
  • 9
  • 22

1 Answers1

1

There are several rules that apply to UNTIL. First of all, it is not an ISO string but of value DATE or DATE-TIME (https://www.rfc-editor.org/rfc/rfc5545#section-3.3.5). Then you need to pay attention that the DATE value is used if the recurring event start is all-day event and vice versa. At last you need to pay attention to Timezone. The UNTIL must be in the same timezone as your start. I really recommend reading about recurrence rules in the RFC https://www.rfc-editor.org/rfc/rfc5545#section-3.8.5.3

Community
  • 1
  • 1
luc
  • 3,642
  • 1
  • 18
  • 21
  • I'm creating events that are 1hr longer. The start time and the end time are outside the recurrence property, do you think that should add these also inside the recurrence rule? – rpasianotto Oct 04 '14 at 09:21
  • No, start and end are separate fields and should not go inside the recurrence. However, the rules that apply to DTSTART and DTEND also apply to start and end in v3. – luc Oct 04 '14 at 09:23
  • So they automatically nested inside, the only problem is to correctly format the UNTIL property at this point. – rpasianotto Oct 04 '14 at 09:33
  • I've added the link to the file on github, maybe it could help. – rpasianotto Oct 04 '14 at 09:34
  • I've found in the resources linked the right date format to use inside the api request. Thanks :) – rpasianotto Oct 04 '14 at 09:49