无法致电Google的全天活动

时间:2015-08-27 16:36:11

标签: javascript events google-calendar-api

我有一个使用Calendar v3 API调用Google日历上所有活动的应用。我可以在附加时间的情况下调用任何事件,但不会显示全天事件。这是我的代码:

  get_calendar: function (name, range, callback, failcount) {
"use strict";
    if (typeof(failcount) === "undefined") {
        failcount = 0;
    }

var startMin, startMax;

// options = $.extend(this.default_opts, options);
var today = Date.today();
var time = [];

switch (range) {
case "today":
  time = [today];
  break;
case "tomorrow":
  time = [today.addDays(1)];
  break;
case "week":
  time = [today,
    today.clone().addDays(7)];
  break;
case "upcoming":
  time = [today];
  break;
default:
  // nil
}

if (time.length > 1) { // if time is more than just one day
  startMin = time[0];
  if (time[1]) {
    startMax = time[1].clone().set({hour: 23, minute: 59, second: 59});
  } else {
    startMax = null;
  }
} else {
  startMin = time[0];
  startMax = time[0].clone().set({hour: 23, minute: 59, second: 59});
}

var events = [];

var request = gapi.client.request({
  path: '/calendar/v3/calendars/' + name + '/events',
  params: {
    timeMin:      startMin.toISOString(),
    timeMax:      startMax.toISOString(),
    singleEvents: true,
    orderBy:      'startTime'
  }
});     

request.then(function(data) {
  var entries = data.result.items;

  for (var i = 0; i < entries.length; i++) {
    var eventEntry = entries[i];
    // var eventTitle = eventEntry.getTitle().getText();
    // console.log('Event title = ' + eventTitle);
    events.push(new Event({
      title: eventEntry.summary,
      start_time: GCal.parse_google_date(eventEntry.start.dateTime),
      end_time: GCal.parse_google_date(eventEntry.end.dateTime),
      location: eventEntry.location,
      description: eventEntry.description
    }));
  }
  // console.log(events);
  // return events;
  callback(events);
},
function() {
  if (failcount >= 3) {
    videoPlayer.queueRefresh();
  } else {
    GCal.get_calendar(name, range, callback, failcount + 1);
  }
});


 },
  parse_google_date: function(dateString) {
    return Date.parse(dateString.substring(0, 19));
  },

然后将此代码链接到:

                  id: "outreach",
              title: "Training & Outreach",
              size: 50,
              content: function() {GCal.get_calendar(tylerTOR, "upcoming", function(data) {
CalData.write_movies(data, "#outreach .content", "s(dddd, MMMM d\nh:mm tt)");
});}
            },
            {
              id: "events",
              size: 50,
              title: "Upcoming Events",
              content: function() {GCal.get_calendar(tylerCal, "week", function(data) {
CalData.write_ticker(data, "#events .content", "s(dddd, MMMM d\nh:mm tt) - e(h:mm tt)");
});}
            }
          ]
        } // #bottomrow
      ]
    }, // #left
    {
      id: "separator",
      size: 1,
      content: function() {$("#separator .content").html("&nbsp;")}
    },
    {
      id: "right",
      orient: "vertical",
      size: 30,
      content: [
        {
          id: "menu",
          title: "Menu",
          size: 33,
              content: function() {GCal.get_calendar(tylerMenu, "week", function(data) {
CalData.write_table(data, "#menu .content", "t()|-|d()");
});}
        },
        {
          id: "events-today",
          title: "Today @ YWAM Tyler",
          size: 33,
          content: function() {GCal.get_calendar(tylerCal, "today", function(data) {
              CalData.write_table(data, "#events-today .content", "s(h:mm) - e(h:mm tt)|-|t()")
            });
          }
        },
        {
          id: "events-tomorrow",
          title: "Tomorrow",
          size: 33, 
          content: function() {GCal.get_calendar(tylerCal, "tomorrow", function(data) {
CalData.write_table(data, "#events-tomorrow .content", "s(h:mm) - e(h:mm tt)|-|t()")
}); }

有关为什么不显示全天活动的任何建议?

0 个答案:

没有答案