1

I have been trying to automate some event creations at the facility I work in. With Google Calendar API I am creating events and adding attendees.

  event = {
            'summary': 'testing the calendar api',
            'start': {'dateTime': '2020-06-04T23:00:00', 'timeZone': 'x/y'},
            'end': {'dateTime': '2020-06-04T23:30:00', 'timeZone': 'x/y'},
            'attendees': [{
                'email': 'x@y'
            }],
            'recurrence': ['RRULE:FREQ=WEEKLY;BYDAY=FR,SA;UNTIL=20200615']
        }

Here despite me specifying which dates the event occurs, I still get one event on the start date. I want to prevent creating the event on the start date unless it falls into the BYDAY params. I tried looking for it on here but couldn't figure it out. Any suggestions?

Community
  • 1
  • 1
sakib11
  • 496
  • 1
  • 5
  • 20

1 Answers1

0

In the Event resource it is announced that "for a recurring event, (the start property) is the start time of the first instance". In your case, the recurrence property determinates to only celebrate the event on fridays and saturdays. Also, the start property of your request falls on a thursday. All this means that the event will be created on fridays, saturday and that initial thursday. If you don't want to create an event on that thurdsday, you can do it just by changing the start/end dates with something similar to this:

{
  "summary": "testing the calendar api",
  "start": {
    "dateTime": "2020-06-05T23:00:00",
    "timeZone": "x/y"
  },
  "end": {
    "dateTime": "2020-06-05T23:30:00",
    "timeZone": "x/y"
  },
  "attendees": [
    {
      "email": "x@y"
    }
  ],
  "recurrence": [
    "RRULE:FREQ=WEEKLY;BYDAY=FR,SA;UNTIL=20200615"
  ]
}

Please, ask me any question if you still have doubts.

Jacques-Guzel Heron
  • 2,480
  • 1
  • 7
  • 16
  • Sorry but I don't understand, so u should forward the dates to match the first occurrence? that is a problem because i will have many events and if I run it on a loop on lets say Sunday and all my dates will start on a specific date , wouldn't that just recreate the problem? – sakib11 Jun 05 '20 at 13:32
  • Hi there @sakib11! Yes, you should use `start.dateTime` as the first occurrence of the event, because it will create an event even if the `recurrence` rule isn't meant to create one on that specific day. You only need to add a logic in your code to adapt the `start.dateTime` to match the first day of the recurrence. As a workaround, you can always use the same dummy date and delete the event created on that specific dummy date just after it's created. – Jacques-Guzel Heron Jun 08 '20 at 11:12
  • Yes fair enough, I suppose I could delete the specific event. Thank you. – sakib11 Jun 08 '20 at 13:32