On Fri, Oct 31, 2008 at 10:05 AM, Pete <[EMAIL PROTECTED]> wrote:
>
> OK, I've been experimenting with the handling of TZ offset issues and
> all day events in the calendar. It wasn't that hard to work around the
> offset issue using Calendar functions in Java and checking to see if
> events returned had a time zone offset or not (0 means it's GMT, add
> my time zone offset. My implementation is as follows.
>
> When next = (When)whens.get(i);
> DateTime st = next.getStartTime();
> DateTime et = next.getEndTime();
> Calendar calStart = Calendar.getInstance();
> Calendar calEnd = Calendar.getInstance();
>
> if (st.getTzShift()) {
> calStart.setTimeInMillis(st.getValue());
> calEnd.setTimeInMillis(et.getValue());
> }
> else {
> tzshift = (calStart.get(calStart.ZONE_OFFSET) +
> calStart.get(calStart.DST_OFFSET));
> calStart.setTimeInMillis(st.getValue() - tzshift);
> calEnd.setTimeInMillis(et.getValue() - tzshift);
> }
>
> However, DST_OFFSET doesn't seem to be working in either OS X 10.5 or
> Fedora 9 (Sun's Java). I'm not sure if I'm doing something wrong or
> what. All events before this weekend come out with the correct time,
> but events past November 1st are an hour earlier than they should be.
> Am I just making some bonehead mistake, or is there something I'm
> missing? Thanks for any help.
>
> Also, what's the status on all day events coming back without a TZ.
> I've seen questions and at least one explanation, but that was from
> several months ago. Is there any news on how to manage this better,
> even if Google doesn't plan on changing/fixing the behavior?
>
> -Pete
Pete,
When you invoke st.getValue() or et.getValue(), you get back an value
representing the number of milliseconds since the Unix epoch, which is
the number of seconds since January 1, 1970 UTC. While Java will apply
a timezone shift, the original timezone applied to the event is
discarded in the output. As a result, calStart/caleEnd don't know what
the timezone shift is.
To fix this, I believe you'll need to set the timezone for calStart
and calEnd by calling calStart.setTimeZone():
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html#setTimeZone
Normally, I'd expect that you could retrieve the name of the current
timezone by calling CalendarEventFeed.getTimeZone(), but this seems to
be returning null for me (possibly a bug?). I don't use the Java
client very often, so if you have any better ideas, let me know.
--
Trevor Johns
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---