开发者

Google Calendar timezone issue

I'm integrating the Google Calendar API with jQuery DatePicker.

My code works fine on every browser except Internet Explorer, as usual.

I currently have this code:

$.getJSON("http://www.google.com/calendar/feeds/developer-calendar@google.com/public/full?alt=json", function(data, textStatus){
    $.each(data.feed.entry, function(index, event){
        if(event.gd$when) {
            var event_date = $.datepicker开发者_如何转开发.formatDate('yymmdd', new Date(event.gd$when[0].startTime));
            if (!(calendar_data.hasOwnProperty(event_date))) {
                calendar_data[event_date] = new Array();
            }
            event.gd$when[0].formatedTime = $.datepicker.formatDate('MM d, yy', new Date(event.gd$when[0].startTime));
            calendar_data[event_date].push(event);
        }
    });
    showEvent(new Date());

    $('#calendar-datepicker').datepicker("refresh");
});

It doesn't work in IE because IE uses the client's timezone to import dates.

Dates from Google Calendar aren't in the local timezone. I've seen that I can add a ctz (custom timezone) to my JSON call, but I can't find any information on it. It's not the timezone offset, I know that much.

My problem: Internet Explorer can't fetch Google Calendar dates. How can I fix this?


Hmmm... drop IE support? screw lame users! I know this is a terrible answer but I'd still vote it up if I see it...

On a serious note, can't you open an exception for ie and account for the math?


new Date(event.gd$when[0].startTime) returns NAN, based on browser

so change

var event_date = $.datepicker.formatDate('yymmdd', new Date(event.gd$when[0].startTime));

to

var event_date = $.datepicker.formatDate('yy-mm-dd', Date.parse(event.gd$when[0].startTime));


Can you manage to get timezoneID of those Google Calendar? If yes then you are set to go. You can convert it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜