Please explain how times work (this differs to my other post)

19 views
Skip to first unread message

Andrew Truckle

unread,
Feb 15, 2012, 11:19:36 AM2/15/12
to google-ca...@googlegroups.com
Hi

My PC is GMT time zone.

I set my google account to GMT-5 Eastern and my calendar to the same (normally GMT).

I synch my data which is all 10am times.

In teh calendar they are set to 5am and 6am.

So it seems to think my entry being added is GMT and compensates. Then tries to be clever and compensates for DST which was not required.

My question is why? At no point to I tell it I am passing in a GMT time and want it converted.

Also, if I set my PC to GMT-5 Eastern and try again it remains at 5am and 6am.

So please advise how I am supposed to synch events so that the times in the calendar match what I pass in?

Thanks.

Andrew

Dan Holevoet

unread,
Feb 16, 2012, 1:18:00 PM2/16/12
to google-ca...@googlegroups.com
Hi Andrew,

Are you passing in a time zone when you are syncing your events? How you do this is language-specific, but in Java it's:

DateTime start = new DateTime(startDate, TimeZone.getTimeZone("UTC"));
event.setStart(new EventDateTime().setDateTime(start));

Replace UTC with whatever time zone you'd like to use.

Thanks,
Dan



Andrew

--
You received this message because you are subscribed to the Google Groups "Google Calendar API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-calendar-api/-/1kAfkv5nLGMJ.
To post to this group, send email to google-ca...@googlegroups.com.
To unsubscribe from this group, send email to google-calendar...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-calendar-api?hl=en.



--
Dan Holevoet
Google Developer Relations

Andrew Truckle

unread,
Feb 17, 2012, 8:45:40 AM2/17/12
to google-ca...@googlegroups.com
I was not passing a time zone. I ended up converting the times to UTC taking DST into account and then passing them with Z suffix and it works.

But unless you get your program to alter the times for the DST they are an hour out when added. Eg:

01-03-2012 10 AM

adds in as 10 AM

But

01-04-2012 10 AM

adds in as 11 AM.

I have to pass

01-04-2012 09 AM

and it adds in as 10 AM.

Fortunately, I found suitable code to take a local time and date and convert it to the UTC time and date (with adjustment for DST) and it now works.

Andrew
Reply all
Reply to author
Forward
0 new messages