Google Calendar
    
    
      
    
    
      
      使用集合让一切井井有条
    
    
      
      根据您的偏好保存内容并对其进行分类。
    
  
    
  
      
    
  
  
  
  
  
    
    
    
  
  
    
    
    
列出主日历上的当日活动
function listAllEventsForToday() {
  var calendarId = 'primary';
  var now = new Date();
  var startOfToday = new Date(now.getYear(), now.getMonth(), now.getDate(),
      0, 0, 0);
  var endOfToday = new Date(now.getYear(), now.getMonth(), now.getDate(),
      23, 59, 29);
  var calendarEvents = Calendar.Events.list(calendarId, {
    timeMin: startOfToday.toISOString(),
    timeMax: endOfToday.toISOString(),
    singleEvents: true,
    orderBy: 'startTime'
  });
  if (calendarEvents.items && calendarEvents.items.length > 0) {
    for (var i = 0; i < calendarEvents.items.length; i++) {
      var calendarEvent = calendarEvents.items[i];
      if (calendarEvent.start.date) {
        // All-day event.
        var start = parseDate(calendarEvent.start.date);
        console.log('%s (%s)', calendarEvent.summary,
                   start.toLocaleDateString());
      } else {
        var start = parseDate(calendarEvent.start.dateTime);
        console.log('%s (%s)', calendarEvent.summary, start.toLocaleString());
      }
    }
  } else {
    console.log('No events found.');
  }
}
获取当前用户的所有日历
function getAllCalendars() {
  var calendarList = Calendar.CalendarList.list();
  for (var i = 0; i < calendarList.items.length; i++) {
    var calendar = calendarList.items[i];
    console.log('%s, %s', calendar.id, calendar.description);
  }
}
在当前用户的某个日历上创建活动
function createEvent() {
  // You can find a Google Calendar's ID from its settings page.
  var calendarId = 'INSERT_CALENDAR_ID_HERE';
  // Nov 1, 2014 10:00:00 AM
  var start = new Date(2014, 10, 1, 10, 0, 0);
  // Nov 1, 2014 11:00:00 AM
  var end = new Date(2014, 10, 1, 11, 0, 0);
  var calendarEvent = {
    summary: 'Run account performance report',
    description: 'Run account performance report for Oct.',
    start: {
      dateTime: start.toISOString()
    },
    end: {
      dateTime: end.toISOString()
    },
    attendees: [
      {email: 'alice@example.com'},
      {email: 'bob@example.com'}
    ],
    // Red background. Use Calendar.Colors.get() for the full list.
    colorId: 11
  };
  calendarEvent = Calendar.Events.insert(calendarEvent, calendarId);
  console.log('New event with ID = %s was created.' + calendarEvent.getId());
}
  
  
  
  
    
  
 
  
    
      
      
    
    
      
    
    
  
       
    
    
      
    
  
  
  如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
  最后更新时间 (UTC):2025-08-21。
  
  
  
    
      [[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-21。"],[],[]]