无法创建重复活动,但只有一个活动有效

时间:2019-06-03 18:09:11

标签: javascript html node.js google-calendar-api

因此,我距离完成Web应用程序仅一步之遥,并且由于重复发生的事件将是主要的吸引力,因此我感到有些沮丧。 即使我尝试通过Google Calendar API模板创建重复活动,也无法正常工作。

主要来源:https://developers.google.com/calendar/create-events 这是我基于的模板:

var event = {
  'summary': 'Google I/O 2015',
  'location': '800 Howard St., San Francisco, CA 94103',
  'description': 'A chance to hear more about Google\'s developer products.',
  'start': {
    'dateTime': '2015-05-28T09:00:00-07:00',
    'timeZone': 'America/Los_Angeles'
  },
  'end': {
    'dateTime': '2015-05-28T17:00:00-07:00',
    'timeZone': 'America/Los_Angeles'
  },
  'recurrence': [
    'RRULE:FREQ=DAILY;COUNT=2'
  ],
};

var request = gapi.client.calendar.events.insert({
  'calendarId': 'primary',
  'resource': event
});

request.execute(function(event) {
  appendPre('Event created: ' + event.htmlLink);
});

注意:

  let event = {
    'summary': title[0], //Name of the show, type: string
    'colorId': '2',
    'description': 'New episode of '+ title[0],
    'start': {
      'dateTime': `${initDate}T${hours}:${minutes}:00+09:00`,
      //Example: '2019-06-17T01:30:00+09:00' 
    },
    'end': {
      'dateTime': `${initDate}T${hourAndMin(hours,minutes)}+09:00`,
      //Same but with +30 mins example: '2019-06-17T02:00:00+09:00'
    },
    'recurrence': [
      'RRULE:FREQ=WEEKLY;UNTIL=20190717' //Example 1 month weekly
      //I have also tried the exact line from the template.
    ],
  };

  let request = gapi.client.calendar.events.insert({
    'calendarId': 'primary',
    'resource': event
  });
  request.execute(function(event) {
    if (event.htmlLink === undefined){
      alert('Error.')
    } else {
      alert('Event created in your Google Calendar.');
    }
  });

当我删除“重复发生”部分时,它可以工作,但是如果我将其保留在那里,则会在浏览器控制台中收到POST 400 Bad Request Error。

1 个答案:

答案 0 :(得分:0)

Google非常明确地要求提供only one timezone进行重复。

我相信您的timeZone计算中存在冲突。您的dateTime建议使用-07:00,但America/Los_Angeles当前是-08:00。最好将timeZone差值与dateTime属性中的开始和结束值相去。这样,Google可以确定偏移量是否有效。夏令时。

相关问题