Google-Calendar API - get offset of the default calendar - google-calendar-api

I want to create an event in Google Calendar using its API setting the start-end time to be 14:00-15:00 according the calendar's timeZone. Following this reference I can create an appointment but I have to pass dateTime formatted according to RFC3339. It demands to know the offset of the calendar's timeZone.
So following this reference I get the default calendar instance, but it has the name of the timeZone without the offset.
What is the way to create an event on a specific date at 14:00-15:00 according the default calendar's timeZone?

To use the default calendar timezone would be to use Zulu timezone which means it "has no offset from Coordinated Universal Time (UTC)" - +8 UTC , those kind of stuff.
Sample from the Events: insert Try-it:
{
"end": {
"dateTime": "2018-06-15T15:00:00Z"
},
"start": {
"dateTime": "2018-06-15T14:00:00Z"
},
"description": "test"
}
But if in turn, you want to use a specific timezone, remove the Z and add the timeZone property
{
"end": {
"dateTime": "2018-06-15T15:00:00",
"timeZone": "Singapore"
},
"start": {
"dateTime": "2018-06-15T14:00:00",
"timeZone": "Singapore"
},
"description": "Singapore"
}
Hope this small sample helps.

Related

Update recurring event after a date

my name is Erick and I'm doing an integration with google calendar.
I need to update the information (without changing the date) of a recurring event from a date other than the first, and I need the changes to be applied in the following schedules.
Ex: Recurring scheduling 2020-07-20 through 2020-07-30
change the summary from the 23rd onwards
call PUT
https://www.googleapis.com/calendar/v3/calendars/{{id}}/events/{{event_id}}
{
"summary": "TESTE 123",
"start": {
"dateTime": "2020-07-23T19:00:00",
"timeZone": "America/Sao_Paulo"
},
"end": {
"dateTime": "2020-07-23T20:00:00",
"timeZone": "America/Sao_Paulo"
}, "recurrence":[
"RRULE:FREQ=DAILY;UNTIL=20200730T235959Z;BYDAY=MO,TU,WE,TH,FR,SA"
]
}
The problem is that when doing it, the days 20, 21 and 22 are excluded,
When there is a change of dates I call the PUT and then the POST to create the other schedules, however, in this case there is no change of date and I cannot miss the recurrence.
I really need some help on this issue, this one, thank you

Getting EXDATE to work when creating Google recurring event

I am trying to import a recurring calendar event using a RRULE plus EXDATE to exclude a date. I thought I had this working a while ago, but it seems to not work any more, at least for this example. The problem is the EXDATE is ignored. See below for sample json. I am trying to exclude the first instance, which begins on June 17, 2019. The date is in Zulu and should match the start date of the event, i.e. 0900 Chicago is 1400 GMT. I have tried including the TZID value of America/Chicago, putting the time in local time (without the Z) and also varying the time up and down by one hour. Google won't budge, the first date is always included in the series. What am I doing wrong?
{
"summary": "Test Meeting 01",
"description": "\n",
"location": "",
"iCalUID": "B8537ED49F7A60558625840A00697C87-Lotus_Notes_Generated-1559329993",
"start": {
"dateTime": "2019-06-17T09:00:00-05:00",
"timeZone": "America/Chicago"
},
"end": {
"dateTime": "2019-06-17T10:00:00-05:00",
"timeZone": "America/Chicago"
},
"recurrence": [
"EXDATE:20190617T140000Z",
"RRULE:FREQ=DAILY;COUNT=3;INTERVAL=1"
],
"attendees": [
],
"visibility": "default"
}
I've been struggling to get EXDATE working too. For me, using local time without TZID or Z worked, i. e.
EXDATE:20190617T090000
for your case.
P.S. This API piece seems really buggy, thus I'll mention that in my case calendar has the same timezone as the event. I do hope, that it does not matter.

What are the accepted datetime format in outlook api while creating events?

I am trying to create an event using Microsoft Graph API. The thing which is a bit confusing are date type parameters such as start which is of type dateTimeTimeZone which has two properties, dateTime and timeZone.
{
"subject": "Test body event graph api ist 1",
"start": {
"dateTime": "2018-01-09T12:00:00",
"timeZone": "India Standard Time"
},
"end": {
"dateTime": "2018-01-09T14:00:00",
"timeZone": "India Standard Time"
},
}
For example, I used the above listed values of start and end datetime. That means the event should be created with start date as 9th,January,2018 and time as 12:00:00 pm IST while it should end in 2:00:00 pm IST. However if I look into my calendar the event was scheduled to start at 6:30 am IST and ending at 8:30 am IST. I cannot understand this behaviour. Can someone explain this?
So what does the two parameters dateTime and timeZone specify? What are the valid dateTime accepted formats and does dateTime format needs to match to the timeZone?
Can someone please explain these things?
You can get a list of supported time zones in the beta version of the Graph API:
GET /me/outlook/supportedTimeZones
The value you are using (India Standard Time) is a valid value, so this should work. I just tried it and it worked correctly.
REQUEST
POST /me/events
{
"subject": "Test India Appt",
"start": {
"dateTime": "2018-01-09T12:00:00",
"timeZone": "India Standard Time"
},
"end": {
"dateTime": "2018-01-09T14:00:00",
"timeZone": "India Standard Time"
}
}
RESPONSE (truncated)
{
...
"originalStartTimeZone": "India Standard Time",
"originalEndTimeZone": "India Standard Time",
...
"subject": "Test India Appt",
...
"start": {
"dateTime": "2018-01-09T12:00:00.0000000",
"timeZone": "India Standard Time"
},
"end": {
"dateTime": "2018-01-09T14:00:00.0000000",
"timeZone": "India Standard Time"
},
...
}
When you say that you looked at your calendar, how did you do that exactly? Depending on the client you used, the display may have been adjusted to a different time zone.
For example, in the Outlook web client, you set your time zone to a specific one and all events are shown relative to that time zone on your calendar. My test user that I created this appointment with has their time zone set to Pacific Standard Time, so when I look at my calendar, the event I created shows as starting at 10:30 PM on 1/8 and ending at 12:30 AM on 1/9.
Outlook desktop client also shows events relative to the user's time zone, but it uses the time zone of the OS rather than relying on its own setting.

Wrong date of recurring events are added in google calendar

When I add an recurring event from one timezone, the UNTIL date shows correctly but the events shown are wrong
For example,
{
"end":
{ "dateTime": "2017-09-26T22:10:00", "timeZone": "America/New_York" },
"start":
{ "dateTime": "2017-09-26T21:50:00", "timeZone": "America/New_York" },
"recurrence": [ "RRULE:FREQ=DAILY;UNTIL=20170929;" ],
"summary": "LEAVE. ",
"location": "New Tover"
}
When I add this, it shows till 28 only but not till 29.
If I set it as a day extra, it takes my offset value of timezone and recurring event differs while adding.
For example, if my timezone is Asia/Culcutta, and if i add a recurring event anytime between morning 12am-5:30am, it shows till 30th and other events till 29th. Please help.

Change an event from all-day to time-limited

There's an all-day event on Google calendar, I pulled it, change it to 1-hour event, I created patch event to push back. As I understand, an all-day event has "start" as a Date, and "end" as the following date. Time-limited event have those in DateTime.
So in my patch, I tried changing those values from Date to DateTime. However, I always receive the error "Invalid or mismatching start and end times".
I tried this manually on Google Calendar API site: https://developers.google.com/google-apps/calendar/v3/reference/events/patch#try-it
and getting the same error. If I take a time-limited event and modify it, no trouble occurs. I believe this is a bug in the API itself. Anyone experiences it and what's the workaround?
Thanks in advance.
Updated: this is what I received from google dev team, hope useful to sb:
Comment #4 on issue 3110 by stanc...#google.com: patching event from all-day to non all-day failed
http://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3110
Patch operation takes the original event and changes/adds/removes entries specified by the request. If you send following request to PATCH operation against all-day event:
{
"start": {
"dateTime": "2012-05-17T06:30:00+06:30",
"timeZone": "UTC"
},
"end": {
"dateTime": "2012-05-17T07:30:00+06:30",
"timeZone": "UTC"
}
}
the resulting event would end-up with both dateTime and date fields set (which is not allowed). Hence, the PATCH request needs to clear the date fields:
{
"start": {
"dateTime": "2012-05-17T06:30:00+06:30",
"timeZone": "UTC",
"date": null
},
"end": {
"dateTime": "2012-05-17T07:30:00+06:30",
"timeZone": "UTC",
"date": null
}
}
In code, when you want to set the field Date to null, you have to put Data.NULL_DATE_TIME like this:
EventDateTime edt = new EventDateTime();
edt.put("date",Data.NULL_DATE_TIME);// if you put NULL, it doesn't retain.
edt.put("dateTime", newTime); //newTime is the new value you want to set, type DateTime
Use the patch https://github.com/google/google-api-php-client/pull/484
It will help you.

Resources