Class CalendarEvent

CalendarEvent

Đại diện cho một sự kiện trên lịch.

Phương thức

Phương thứcLoại dữ liệu trả vềMô tả ngắn
addEmailReminder(minutesBefore)CalendarEventThêm lời nhắc mới qua email vào sự kiện.
addGuest(email)CalendarEventThêm khách vào sự kiện.
addPopupReminder(minutesBefore)CalendarEventThêm thông báo bật lên mới vào sự kiện.
addSmsReminder(minutesBefore)CalendarEventThêm lời nhắc mới qua SMS vào sự kiện.
anyoneCanAddSelf()BooleanXác định xem mọi người có thể tự thêm mình làm khách vào một sự kiện trên Lịch hay không.
deleteEvent()voidXoá một sự kiện trên Lịch.
deleteTag(key)CalendarEventXoá thẻ khoá/giá trị khỏi sự kiện.
getAllDayEndDate()DateLấy ngày kết thúc sự kiện cả ngày này trên lịch.
getAllDayStartDate()DateLấy ngày bắt đầu sự kiện cả ngày này trên lịch.
getAllTagKeys()String[]Lấy tất cả khoá của các thẻ đã được đặt cho sự kiện.
getColor()StringTrả về màu của sự kiện trên lịch.
getCreators()String[]Tải người tạo của một sự kiện.
getDateCreated()DateXem ngày tạo sự kiện.
getDescription()StringXem nội dung mô tả của sự kiện.
getEmailReminders()Integer[]Lấy giá trị phút cho tất cả lời nhắc qua email cho sự kiện.
getEndTime()DateLấy ngày và giờ kết thúc sự kiện trên lịch này.
getEventSeries()CalendarEventSeriesLấy chuỗi sự kiện định kỳ có chứa sự kiện này.
getGuestByEmail(email)EventGuestNhận khách qua địa chỉ email.
getGuestList()EventGuest[]Nhận khách cho sự kiện, không bao gồm chủ sở hữu sự kiện.
getGuestList(includeOwner)EventGuest[]Nhận khách cho sự kiện, có thể bao gồm chủ sở hữu sự kiện.
getId()StringLấy iCalUID duy nhất của sự kiện.
getLastUpdated()DateXem ngày gần đây nhất mà sự kiện được cập nhật.
getLocation()StringLấy vị trí của sự kiện.
getMyStatus()GuestStatusXem trạng thái sự kiện (chẳng hạn như đang tham dự hoặc được mời) của người dùng hiệu quả.
getOriginalCalendarId()StringLấy mã lịch của sự kiện này ban đầu.
getPopupReminders()Integer[]Lấy giá trị phút cho tất cả lời nhắc bật lên cho sự kiện.
getSmsReminders()Integer[]Lấy giá trị phút cho tất cả lời nhắc qua SMS cho sự kiện.
getStartTime()DateLấy ngày và giờ mà sự kiện trên lịch này bắt đầu.
getTag(key)StringNhận giá trị thẻ của sự kiện.
getTitle()StringLấy tiêu đề của sự kiện.
getVisibility()VisibilityXem chế độ hiển thị của sự kiện.
guestsCanInviteOthers()BooleanXác định xem khách có thể mời khách khác hay không.
guestsCanModify()BooleanXác định xem khách có thể sửa đổi sự kiện hay không.
guestsCanSeeGuests()BooleanXác định xem khách có thể nhìn thấy khách khác không.
isAllDayEvent()BooleanXác định xem đây có phải là sự kiện cả ngày hay không.
isOwnedByMe()BooleanXác định xem bạn có phải là chủ sở hữu của sự kiện hay không.
isRecurringEvent()BooleanXác định xem sự kiện đó có thuộc một chuỗi sự kiện hay không.
removeAllReminders()CalendarEventXóa tất cả lời nhắc khỏi sự kiện.
removeGuest(email)CalendarEventXoá khách khỏi sự kiện.
resetRemindersToDefault()CalendarEventĐặt lại lời nhắc bằng cách sử dụng cài đặt mặc định của lịch.
setAllDayDate(date)CalendarEventĐặt ngày của sự kiện.
setAllDayDates(startDate, endDate)CalendarEventĐặt ngày diễn ra sự kiện.
setAnyoneCanAddSelf(anyoneCanAddSelf)CalendarEventĐặt xem những người không phải là khách có thể tự thêm chính mình vào sự kiện hay không.
setColor(color)CalendarEventĐặt màu cho sự kiện trên lịch.
setDescription(description)CalendarEventĐặt nội dung mô tả cho sự kiện.
setGuestsCanInviteOthers(guestsCanInviteOthers)CalendarEventĐặt xem khách có thể mời khách khác không.
setGuestsCanModify(guestsCanModify)CalendarEventĐặt xem khách có thể sửa đổi sự kiện hay không.
setGuestsCanSeeGuests(guestsCanSeeGuests)CalendarEventĐặt xem khách có thể nhìn thấy khách khác không.
setLocation(location)CalendarEventĐặt địa điểm cho sự kiện.
setMyStatus(status)CalendarEventĐặt trạng thái sự kiện (chẳng hạn như đang tham dự hoặc được mời) của người dùng hiệu quả.
setTag(key, value)CalendarEventĐặt thẻ khoá/giá trị cho sự kiện để lưu trữ siêu dữ liệu tuỳ chỉnh.
setTime(startTime, endTime)CalendarEventĐặt ngày và giờ cho thời điểm bắt đầu và kết thúc sự kiện.
setTitle(title)CalendarEventĐặt tiêu đề cho sự kiện.
setVisibility(visibility)CalendarEventĐặt chế độ hiển thị của sự kiện.

Tài liệu chi tiết

addEmailReminder(minutesBefore)

Thêm lời nhắc mới qua email vào sự kiện. Lời nhắc phải dài ít nhất 5 phút và tối đa là 4 phút tuần (40320 phút), trước khi sự kiện diễn ra.

// Gets an event by its ID. For an event series, use getEventSeriesById(iCalId) instead.
// TODO(developer): Replace the string with the event ID that you want to get.
const event = CalendarApp.getEventById('abc123456');

// Adds an email notification for 15 minutes before the event.
event.addEmailReminder(15);

Tham số

TênLoạiMô tả
minutesBeforeIntegersố phút trước sự kiện

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Gửi

Error – nếu có nhiều hơn 5 lời nhắc trên sự kiện hoặc thời gian không trong phạm vi pháp lý

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

addGuest(email)

Thêm khách vào sự kiện.

// Example 1: Add a guest to one event
function addAttendeeToEvent() {
  // Replace the below values with your own
  let attendeeEmail = 'user@example.com'; // Email address of the person you need to add
  let calendarId = 'calendar_123@group.calendar.google.com'; // ID of calendar containing event
  let eventId = '123abc'; // ID of event instance

  let calendar = CalendarApp.getCalendarById(calendarId);
  if (calendar === null) {
    // Calendar not found
    console.log('Calendar not found', calendarId);
    return;
    }
  let event = calendar.getEventById(eventId);
  if (event === null) {
    // Event not found
    console.log('Event not found', eventId);
    return;
    }
  event.addGuest(attendeeEmail);
  }

// Example 2: Add a guest to all events on a calendar within a specified timeframe
function addAttendeeToAllEvents(){
// Replace the following values with your own
  let attendeeEmail = 'user@example.com'; // Email address of the person you need to add
  let calendarId = 'calendar_123@group.calendar.google.com'; // ID of calendar with the events
  let startDate = new Date("YYYY-MM-DD"); // The first date to add the guest to the events
  let endDate = new Date("YYYY-MM-DD"); // The last date to add the guest to the events

  let calendar = CalendarApp.getCalendarById(calendarId);
    if (calendar === null) {
    // Calendar not found
    console.log('Calendar not found', calendarId);
    return;
  }
  // Get the events within the specified timeframe
  let calEvents = calendar.getEvents(startDate,endDate);
  console.log(calEvents.length); // Checks how many events are found
  // Loop through all events and add the attendee to each of them
  for (var i = 0; i < calEvents.length; i++) {
  let event = calEvents[i];
  event.addGuest(attendeeEmail);
  }
}

Tham số

TênLoạiMô tả
emailStringĐịa chỉ email của khách.

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi.

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

addPopupReminder(minutesBefore)

Thêm thông báo bật lên mới vào sự kiện. Thông báo phải dài ít nhất 5 phút và tối đa 4 tuần (40320 phút), trước khi sự kiện diễn ra.

// Gets an event by its ID. For an event series, use getEventSeriesById(iCalId) instead.
// TODO(developer): Replace the string with the event ID that you want to get.
const event = CalendarApp.getEventById('abc123456');

// Adds a pop-up notification for 15 minutes before the event.
event.addPopupReminder(15);

Tham số

TênLoạiMô tả
minutesBeforeIntegersố phút trước sự kiện

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

addSmsReminder(minutesBefore)

Thêm lời nhắc mới qua SMS vào sự kiện. Lời nhắc phải dài ít nhất 5 phút và tối đa là 4 phút tuần (40320 phút), trước khi sự kiện diễn ra.

Tham số

TênLoạiMô tả
minutesBeforeIntegersố phút trước sự kiện

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Gửi

Error – nếu có nhiều hơn 5 lời nhắc trên sự kiện hoặc thời gian không trong phạm vi pháp lý

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

anyoneCanAddSelf()

Xác định xem mọi người có thể tự thêm mình làm khách vào một sự kiện trên Lịch hay không.

// Gets an event by its ID. For an event series, use getEventSeriesById(iCalId) instead.
// TODO(developer): Replace the string with the event ID that you want to get.
const event = CalendarApp.getEventById('abc123456');

// Determines whether people can add themselves as guests to the event and logs it.
console.log(event.anyoneCanAddSelf());

Cầu thủ trả bóng

Booleantrue nếu khách không phải là khách có thể tự thêm chính mình vào sự kiện; false nếu không

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

deleteEvent()

Xoá một sự kiện trên Lịch.

// Gets an event by its ID.
// TODO(developer): Replace the string with the ID of the event that you want to delete.
const event = CalendarApp.getEventById('abc123456');

// Deletes the event.
event.deleteEvent();

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

deleteTag(key)

Xoá thẻ khoá/giá trị khỏi sự kiện.

Tham số

TênLoạiMô tả
keyStringkhoá thẻ

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

getAllDayEndDate()

Lấy ngày kết thúc sự kiện cả ngày này trên lịch. (Nếu đây không phải là sự kiện cả ngày thì phương thức này gửi ra một ngoại lệ.) Date được trả về đại diện cho nửa đêm lúc đầu ngày sau khi sự kiện kết thúc theo múi giờ của tập lệnh. Để sử dụng múi giờ của lịch, hãy gọi getEndTime().

// Gets the user's default calendar. To get a different calendar, use getCalendarById()
// instead.
const calendar = CalendarApp.getDefaultCalendar();

// Creates an event named 'My all-day event' for May 16, 2023.
const event = calendar.createAllDayEvent('My all-day event', new Date('May 16, 2023'));

// Gets the event's end date and logs it.
const endDate = event.getAllDayEndDate();
console.log(endDate);

Cầu thủ trả bóng

Date — ngày kết thúc của sự kiện trên lịch cả ngày này

Gửi

Error — nếu sự kiện này không phải là sự kiện cả ngày

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getAllDayStartDate()

Lấy ngày bắt đầu sự kiện cả ngày này trên lịch. (Nếu đây không phải là sự kiện cả ngày, thì phương thức này sẽ gửi ra một ngoại lệ.) Date được trả về đại diện cho nửa đêm lúc đầu ngày mà sự kiện bắt đầu theo múi giờ của tập lệnh. Để sử dụng múi giờ của lịch, hãy gọi getStartTime().

// Gets the user's default calendar. To get a different calendar, use getCalendarById()
// instead.
const calendar = CalendarApp.getDefaultCalendar();

// Creates an event named 'My all-day event' for May 16, 2023.
const event = calendar.createAllDayEvent('My all-day event', new Date('May 16, 2023'));

// Gets the event's start date and logs it.
const startDate = event.getAllDayStartDate();
console.log(startDate);

Cầu thủ trả bóng

Date — ngày bắt đầu của sự kiện trên lịch cả ngày này

Gửi

Error — nếu sự kiện này không phải là sự kiện cả ngày

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getAllTagKeys()

Lấy tất cả khoá của các thẻ đã được đặt cho sự kiện.

Cầu thủ trả bóng

String[] – một mảng các khoá chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getColor()

Trả về màu của sự kiện trên lịch.

// Gets an event by its ID. For an event series, use getEventSeriesById(iCalId) instead.
// TODO(developer): Replace the string with the event ID that you want to get.
const event = CalendarApp.getEventById('abc123456');

// Gets the color of the calendar event and logs it.
const eventColor = event.getColor();
console.log(eventColor);

Cầu thủ trả bóng

String – Chuỗi đại diện của màu sự kiện, dưới dạng chỉ mục (1-11) của các giá trị từ CalendarApp.EventColor.

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getCreators()

Tải người tạo của một sự kiện.

// Gets an event by its ID. For an event series, use getEventSeriesById(iCalId) instead.
// TODO(developer): Replace the string with the event ID that you want to get.
const event = CalendarApp.getEventById('abc123456');

// Gets a list of the creators of the event and logs it.
console.log(event.getCreators());

Cầu thủ trả bóng

String[] — địa chỉ email của những người tạo sự kiện

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getDateCreated()

Xem ngày tạo sự kiện. Bạn phải có quyền truy cập vào lịch.

// Opens the calendar by using its ID.
// To get the user's default calendar use CalendarApp.getDefault() instead.
// TODO(developer): Replace the calendar ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 8:10 AM and 4:25 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 01, 2023 08:10:00'), new Date('Feb 01, 2023 16:25:00'))[0];

if (event) {
 // If an event exists within the given time frame, gets the date that the event
 // was created and logs it.
 const eventCreated = event.getDateCreated();
 console.log(eventCreated);
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

Date – ngày tạo

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getDescription()

Xem nội dung mô tả của sự kiện. Bạn phải có quyền chỉnh sửa lịch.

// Opens the calendar by its ID.
// To get the user's default calendar use CalendarApp.getDefault() instead.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 4th, 2023 that takes place
between 4:00 PM and 5:00 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 04, 2023 16:00:00'), new Date('Feb 04, 2023 17:00:00'))[0];

if (event) {
 // If an event exists within the given time frame, sets the description of the event.
 event.setDescription('Important meeting');

 // Gets the description of the event and logs it.
 const description = event.getDescription();
 console.log(description);
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

String — nội dung mô tả

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getEmailReminders()

Lấy giá trị phút cho tất cả lời nhắc qua email cho sự kiện. Bạn phải có quyền chỉnh sửa đối với lịch.

// Opens the calendar by its ID.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 4th, 2023 that takes place
between 5:00 PM and 6:00 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 04, 2023 15:00:00'), new Date('Feb 04, 2023 18:00:00'))[0];

if (event) {
 // If an event exists within the given time frame, adds email reminders for the user to be
 // sent at 4 and 7 minutes before the event.
 event.addEmailReminder(4);
 event.addEmailReminder(7);

 // Gets the minute values for all email reminders that are set up for the user for this event
 // and logs it.
 const emailReminder = event.getEmailReminders();
 console.log(emailReminder);
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

Integer[] – một mảng mà trong đó mỗi giá trị tương ứng với số phút trước khi sự kiện xảy ra một lời nhắc kích hoạt

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getEndTime()

Lấy ngày và giờ kết thúc sự kiện trên lịch này. Bạn phải có quyền truy cập vào lịch. Đối với các sự kiện không diễn ra cả ngày, đây là thời điểm mà sự kiện được xác định kết thúc. Đối với các sự kiện cả ngày chỉ lưu trữ ngày kết thúc (không phải ngày và giờ), thời gian này là nửa đêm vào đầu ngày sau khi sự kiện kết thúc theo múi giờ của lịch. Chiến dịch này cho phép so sánh có ý nghĩa thời gian kết thúc của tất cả các loại sự kiện; tuy nhiên, nó không nhất thiết phải giữ ngày gốc trong năm không bị sửa đổi.

Đối với các sự kiện cả ngày, getAllDayEndDate() sẽ gần như sẽ luôn được gọi theo tuỳ chọn cho phương thức này.

// Opens the calendar by its ID.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 4:00 PM and 5:00 PM.
const event =
  calendar.getEvents(new Date('Feb 01, 2023 16:00:00'), new Date('Feb 01, 2023 17:00:00'))[0];

if (event) {
 // If an event exists within the given time frame, gets the date and time at which the
 // event ends and logs it.
 console.log(event.getEndTime());
} else {
 // If no event exists within the given time frame, logs that info to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

Date — thời gian kết thúc của sự kiện trên lịch này

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getEventSeries()

Lấy chuỗi sự kiện định kỳ có chứa sự kiện này. Bạn phải có quyền truy cập vào lịch. Đối tượng CalendarEventSeries được trả về ngay cả khi sự kiện này không thuộc về một chuỗi chủ đề để bạn có thể thêm cài đặt lặp lại mới.

// Opens the calendar by its ID.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 18th, 2023 that takes place between
// 1:00 PM and 2:00 PM.
const event =
  calendar.getEvents(new Date('Feb 18, 2023 13:00:00'), new Date('Feb 18, 2023 14:00:00'))[0];

if (event) {
 // If an event exists within the given time frame, gets the event series for the event
 // and sets the color to pale green.
 event.getEventSeries().setColor(CalendarApp.EventColor.PALE_GREEN);
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

CalendarEventSeries – chuỗi sự kiện chứa sự kiện này hoặc một chuỗi sự kiện mới nếu chưa thuộc sang một loạt phim

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getGuestByEmail(email)

Nhận khách qua địa chỉ email.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 25th, 2023 that takes place
// between 5:00 PM and 5:25 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 25,2023 17:00:00'), new Date('Feb 25,2023 17:25:00'))[0];

// Gets a guest by email address.
const guestEmailId = event.getGuestByEmail('alex@example.com');

// If the email address corresponds to an event guest, logs the email address.
if (guestEmailId) {
  console.log(guestEmailId.getEmail());
}

Tham số

TênLoạiMô tả
emailStringđịa chỉ của khách

Cầu thủ trả bóng

EventGuest — khách hoặc rỗng nếu địa chỉ email không tương ứng với một khách

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

getGuestList()

Nhận khách cho sự kiện, không bao gồm chủ sở hữu sự kiện.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 25th, 2023 that takes place
// between 5:00 PM and 5:25 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 25,2023 17:00:00'), new Date('Feb 25,2023 17:25:00'))[0];

// Adds two guests to the event by using their email addresses.
event.addGuest('alex@example.com');
event.addGuest('cruz@example.com');

// Gets the guests list for the event.
const guestList = event.getGuestList();

// Loops through the list to get all the guests and logs their email addresses.
for (const guest of guestList){
  console.log(guest.getEmail());
}

Cầu thủ trả bóng

EventGuest[] — một loạt khách

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getGuestList(includeOwner)

Nhận khách cho sự kiện, có thể bao gồm chủ sở hữu sự kiện.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 25th, 2023 that takes place
// between 5:00 PM and 5:25 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 25,2023 17:00:00'), new Date('Feb 25,2023 17:25:00'))[0];

// Gets the guests list for the event, including the owner of the event.
const guestList = event.getGuestList(true);

// Loops through the list to get all the guests and logs it.
for (const guest of guestList) {
  console.log(guest.getEmail());
}

Tham số

TênLoạiMô tả
includeOwnerBooleancó nên thêm chủ sở hữu làm khách hay không

Cầu thủ trả bóng

EventGuest[] — một loạt khách

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getId()

Lấy iCalUID duy nhất của sự kiện. Xin lưu ý rằng iCalUID và sự kiện idAPI Lịch phiên bản 3Dịch vụ nâng cao của Lịch không giống nhau và không thể sử dụng thay thế cho nhau. Một điểm khác biệt về ngữ nghĩa là trong các sự kiện định kỳ tất cả lần xuất hiện của một sự kiện đều có ids khác nhau trong khi tất cả đều dùng chung một iCalUID.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for January 5th, 2023 that takes place
// between 9:00 AM and 9:25 AM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Jan 05, 2023 09:00:00'), new Date('Jan 05, 2023 09:25:00'))[0];

// Gets the ID of the event and logs it.
console.log(event.getId());

Cầu thủ trả bóng

String – iCalUID của sự kiện

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getLastUpdated()

Xem ngày gần đây nhất mà sự kiện được cập nhật.

// Opens the calendar by its ID. You must have view access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
between 4:00 PM and 5:00 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 01, 2023 16:00:00'), new Date('Feb 01, 2023 17:00:00'))[0];

// Gets the date the event was last updated and logs it.
const eventUpdatedDate = event.getLastUpdated();
console.log(eventUpdatedDate);

Cầu thủ trả bóng

Date – ngày cập nhật gần đây nhất

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getLocation()

Lấy vị trí của sự kiện.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 4:10 PM and 4:25 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 01, 2023 16:10:00'), new Date('Feb 01, 2023 16:25:00'))[0];

if (event) {
 // If an event exists within the given time frame, sets the location of the event to Mumbai.
 event.setLocation('Mumbai');

 // Gets the location of the event and logs it.
 const eventLocation = event.getLocation();
 console.log(eventLocation);
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

String – địa điểm diễn ra sự kiện

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getMyStatus()

Xem trạng thái sự kiện (chẳng hạn như đang tham dự hoặc được mời) của người dùng hiệu quả. Luôn trả lại hàng GuestStatus.OWNER nếu người dùng hiệu quả là chủ sở hữu sự kiện.

// Opens the calendar by its ID.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 4:10 PM and 4:25 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 01, 2023 16:10:00'), new Date('Feb 01, 2023 16:25:00'))[0];

if (event) {
 // If an event exists within the given time frame, gets the event status of
 // the effective user and logs it.
 const myStatus = event.getMyStatus();
 console.log(myStatus.toString());
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

GuestStatus – trạng thái

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getOriginalCalendarId()

Lấy mã lịch của sự kiện này ban đầu.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 25th, 2023 that takes place
// between 4:00 PM and 4:25 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 25,2023 16:00:00'), new Date('Feb 25,2023 16:25:00'))[0];

if (event) {
 // If an event exists within the given time frame, gets the ID of the calendar where the
 // event was originally created and logs it.
 const calendarId = event.getOriginalCalendarId();
 console.log(calendarId);
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

String — ID của lịch gốc

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getPopupReminders()

Lấy giá trị phút cho tất cả lời nhắc bật lên cho sự kiện.

  // Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 4th, 2023 that takes place
// between 5:05 PM and 5:35 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 04, 2023 17:05:00'), new Date('Feb 04, 2023 17:35:00'))[0];

if (event) {
 // If an event exists within the given time frame, adds two pop-up reminders to the event.
 // The first reminder pops up 5 minutes before the event starts and the second reminder
 // pops up 3 minutes before the event starts.
 event.addPopupReminder(3);
 event.addPopupReminder(5);

 // Gets the minute values for all pop-up reminders for the event and logs it.
 const popUpReminder = event.getPopupReminders();
 console.log(popUpReminder);
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

Integer[] – một mảng mà trong đó mỗi giá trị tương ứng với số phút trước khi sự kiện xảy ra một lời nhắc kích hoạt

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getSmsReminders()

Lấy giá trị phút cho tất cả lời nhắc qua SMS cho sự kiện.

Cầu thủ trả bóng

Integer[] – một mảng mà trong đó mỗi giá trị tương ứng với số phút trước khi sự kiện xảy ra một lời nhắc kích hoạt

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getStartTime()

Lấy ngày và giờ bắt đầu sự kiện trên lịch này. Đối với các sự kiện không diễn ra cả ngày, là thời điểm mà sự kiện được xác định để bắt đầu. Đối với các sự kiện cả ngày, điều này chỉ lưu trữ ngày bắt đầu (không phải ngày và giờ), đây là thời điểm nửa đêm đầu ngày mà sự kiện bắt đầu theo múi giờ của lịch. Điều này cho phép so sánh có ý nghĩa giữa thời gian bắt đầu cho tất cả các loại sự kiện; tuy nhiên, kết quả này không nhất thiết giữ nguyên bản gốc ngày trong năm không sửa đổi.

Đối với các sự kiện cả ngày, getAllDayStartDate() sẽ hầu như luôn được gọi tuỳ theo phương thức này.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 4:10 PM and 4:25 PM.
const event =
  calendar.getEvents(new Date('Feb 01, 2023 16:10:00'), new Date('Feb 01, 2023 16:25:00'))[0];

// Gets the date and time at which this calendar event begins and logs it.
const startTime = event.getStartTime();
console.log(startTime);

Cầu thủ trả bóng

Date — thời gian bắt đầu sự kiện trên lịch này

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getTag(key)

Nhận giá trị thẻ của sự kiện.

Tham số

TênLoạiMô tả
keyStringkhoá

Cầu thủ trả bóng

String – giá trị thẻ

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getTitle()

Lấy tiêu đề của sự kiện.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for January 31st, 2023 that takes place
// between 9:05 AM and 9:15 AM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Jan 31, 2023 09:05:00'), new Date('Jan 31, 2023 09:15:00'))[0];

if (event) {
 // If an event exists within the given time frame, logs the title of the event.
 console.log(event.getTitle());
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

String – tiêu đề

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

getVisibility()

Xem chế độ hiển thị của sự kiện.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 4:10 PM and 4:25 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 01, 2023 16:10:00'), new Date('Feb 01, 2023 16:25:00'))[0];

if (event) {
 // If an event exists within the given time frame, gets the visibility of the event
 // and logs it.
 const eventVisibility = event.getVisibility();
 console.log(eventVisibility.toString());
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

Visibility – giá trị của chế độ hiển thị

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

guestsCanInviteOthers()

Xác định xem khách có thể mời khách khác hay không.

// Opens the calendar by its ID. You must have view access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 9:35 AM and 9:40 AM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 01, 2023 09:35:00'), new Date('Feb 01, 2023 09:40:00'))[0];

if (event) {
 // If an event exists within the given time frame, determines whether guests can invite
 // other guests and logs it.
 console.log(event.guestsCanInviteOthers());
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

Booleantrue nếu khách có thể mời người khác; false nếu không

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

guestsCanModify()

Xác định xem khách có thể sửa đổi sự kiện hay không.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 9:35 AM and 9:40 AM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 01, 2023 09:35:00'), new Date('Feb 01, 2023 09:40:00'))[0];

if (event) {
 // If an event exists within the given time frame, sets the event so that guests can't
 // modify it.
 event.setGuestsCanModify(false);

 // Determines whether guests can modify the event and logs it.
 console.log(event.guestsCanModify());
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

Booleantrue nếu khách có thể sửa đổi sự kiện; false nếu không

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

guestsCanSeeGuests()

Xác định xem khách có thể nhìn thấy khách khác không.

// Opens the calendar by its ID. You must have view access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 9:35 AM and 9:40 AM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 01, 2023 09:35:00'), new Date('Feb 01, 2023 09:40:00'))[0];

if (event) {
 // If an event exists within the given time frame, determines whether guests can see other
 // guests and logs it.
 console.log(event.guestsCanSeeGuests());
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

Booleantrue nếu khách có thể nhìn thấy những khách khác; false nếu không

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

isAllDayEvent()

Xác định xem đây có phải là sự kiện cả ngày hay không.

// Opens the calendar by its ID. You must have view access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for January 31st, 2023 that takes place
// between 9:05 AM and 9:15 AM.
const event =
  calendar.getEvents(new Date('Jan 31, 2023 09:05:00'), new Date('Jan 31, 2023 09:15:00'))[0];

// Determines whether this event is an all-day event and logs it.
console.log(event.isAllDayEvent());

Cầu thủ trả bóng

Booleantrue nếu sự kiện diễn ra cả ngày; false nếu không

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

isOwnedByMe()

Xác định xem bạn có phải là chủ sở hữu của sự kiện hay không.

// Opens the calendar by its ID. You must have view access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for January 31st, 2023 that takes place
// between 9:05 AM and 9:15 AM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Jan 31, 2023 09:05:00'), new Date('Jan 31, 2023 09:15:00'))[0];

if (event) {
 // If an event exists within the given time frame, determines whether you're the owner
 // of the event and logs it.
 console.log(event.isOwnedByMe());
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

Booleantrue nếu sự kiện thuộc sở hữu của người dùng có hiệu lực; false nếu không

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

isRecurringEvent()

Xác định xem sự kiện đó có thuộc một chuỗi sự kiện hay không.

// Opens the calendar by its ID. You must have view access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for Januart 31st, 2023 that takes place
// between 9:00 AM and 10:00 AM.
const event =
  calendar.getEvents(new Date('Jan 31, 2023 09:00:00'), new Date('Jan 31, 2023 10:00:00'))[0];

if (event) {
 // If an event exists within the given time frame, determines whether the event is part of an
 // event series and logs it.
 console.log(event.isRecurringEvent());
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

Booleantrue nếu sự kiện nằm trong chuỗi sự kiện; false nếu không

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

removeAllReminders()

Xóa tất cả lời nhắc khỏi sự kiện.

// Opens the calendar by its ID. You must have edit access to the calendar
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 4:10 PM and 4:25 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 1,2023 16:10:00'), new Date('Feb 1,2023 16:25:00'))[0];

if (event) {
 // If an event exists within the given time frame, removes all reminders from the event.
 event.removeAllReminders();
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

removeGuest(email)

Xoá khách khỏi sự kiện.

// Example 1: Remove a guest from one event
function removeGuestFromEvent() {
  // Replace the below values with your own
  let attendeeEmail = 'user@example.com'; // Email address of the person you need to remove
  let calendarId = 'calendar_123@group.calendar.google.com'; // ID of calendar containing event
  let eventId = '123abc'; // ID of event instance

  let calendar = CalendarApp.getCalendarById(calendarId);
  if (calendar === null) {
    // Calendar not found
    console.log('Calendar not found', calendarId);
    return;
    }
  let event = calendar.getEventById(eventId);
  if (event === null) {
    // Event not found
    console.log('Event not found', eventId);
    return;
    }
  event.removeGuest(attendeeEmail);
  }

// Example 2: Remove a guest from all events on a calendar within a specified timeframe
function removeGuestFromAllEvents(){
// Replace the following values with your own
  let attendeeEmail = 'user@example.com'; // Email address of the person you need to remove
  let calendarId = 'calendar_123@group.calendar.google.com'; // ID of calendar with the events
  let startDate = new Date("YYYY-MM-DD"); // The first date to remove the guest from the events
  let endDate = new Date("YYYY-MM-DD"); // The last date to remove the attendee from the events

  let calendar = CalendarApp.getCalendarById(calendarId);
    if (calendar === null) {
    // Calendar not found
    console.log('Calendar not found', calendarId);
    return;
  }
  // Get the events within the specified timeframe
  let calEvents = calendar.getEvents(startDate,endDate);
  console.log(calEvents.length); // Checks how many events are found
  // Loop through all events and remove the attendee from each of them
  for (var i = 0; i < calEvents.length; i++) {
  let event = calEvents[i];
  event.removeGuest(attendeeEmail);
  }
}

Tham số

TênLoạiMô tả
emailStringđịa chỉ email của khách

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

resetRemindersToDefault()

Đặt lại lời nhắc bằng cách sử dụng cài đặt mặc định của lịch.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 4:10 PM and 4:25 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 1, 2023 16:10:00'), new Date('Feb 1, 2023 16:25:00'))[0];

if (event) {
 // If an event exists within the given time frame, resets the reminders using the calendar's
 // default settings.
 event.resetRemindersToDefault();
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setAllDayDate(date)

Đặt ngày của sự kiện. Khi bạn áp dụng phương thức này, một sự kiện thông thường sẽ thay đổi thành sự kiện cả ngày.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 17th, 2023 that takes place
// between 4:00 PM and 5:00 PM.
const event =
  calendar.getEvents(new Date('Feb 17, 2023 16:00:00'), new Date('Feb 17, 2023 17:00:00'))[0];

if (event) {
 // If an event exists within the given time frame, sets the date of the event and updates
 // it to an all-day event.
 event.setAllDayDate(new Date('Feb 17, 2023'));
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Tham số

TênLoạiMô tả
dateDatengày diễn ra sự kiện (thời gian bị bỏ qua)

Cầu thủ trả bóng

CalendarEvent — CalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setAllDayDates(startDate, endDate)

Đặt ngày diễn ra sự kiện. Khi bạn áp dụng phương thức này, một sự kiện thông thường sẽ thay đổi thành cả ngày sự kiện.

// Opens the calendar by its ID.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 18th, 2023 that takes place
// between 4:00 PM and 5:00 PM.
const event =
  calendar.getEvents(new Date('Feb 18, 2023 16:00:00'), new Date('Feb 18, 2023 17:00:00'))[0];

if (event) {
 // If an event exists within the given time frame, sets the event to be an all-day event from
 // Feb 18th, 2023 until Feb 25th, 2023. Applying this method changes a regular event into an
 // all-day event.
 event.setAllDayDates(new Date('Feb 18, 2023'), new Date('Feb 25, 2023'));
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Tham số

TênLoạiMô tả
startDateDatengày bắt đầu sự kiện (thời gian bị bỏ qua)
endDateDatengày kết thúc sự kiện (thời gian bị bỏ qua)

Cầu thủ trả bóng

CalendarEvent — CalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setAnyoneCanAddSelf(anyoneCanAddSelf)

Đặt xem những người không phải là khách có thể tự thêm chính mình vào sự kiện hay không.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 15th, 2023 that takes place
// between 3:30 PM and 4:30 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 15, 2023 15:30:00'), new Date('Feb 15, 2023 16:30:00'))[0];

if (event) {
 // If an event exists within the given time frame, sets the event so that non-guests
 // can't add themselves to the event.
 event.setAnyoneCanAddSelf(false);
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Tham số

TênLoạiMô tả
anyoneCanAddSelfBooleanliệu mọi người có thể tự mời mình hay không

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setColor(color)

Đặt màu cho sự kiện trên lịch.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 4:10 PM and 4:25 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 01, 2023 16:10:00'), new Date('Feb 01, 2023 16:25:00'))[0];

if (event) {
 // If an event exists within the given time frame, sets the color of the calendar event to
 // green.
 event.setColor(CalendarApp.EventColor.GREEN);
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Tham số

TênLoạiMô tả
colorStringChỉ mục màu số nguyên dưới dạng chuỗi hoặc giá trị từ CalendarApp.EventColor.

Cầu thủ trả bóng

CalendarEvent — Sự kiện trên lịch này, để tạo chuỗi.

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setDescription(description)

Đặt nội dung mô tả cho sự kiện.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 4th, 2023 that takes place
// between 5:05 PM and 5:35 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 04, 2023 17:05:00'), new Date('Feb 04, 2023 17:35:00'))[0];

if (event) {
 // If an event exists within the given time frame, sets the description of the event to
 // 'Meeting.'
 event.setDescription('Meeting');
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Tham số

TênLoạiMô tả
descriptionStringnội dung mô tả mới

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setGuestsCanInviteOthers(guestsCanInviteOthers)

Đặt xem khách có thể mời khách khác không.

// Opens the calendar by its ID.
// TODO(developer): Replace the ID with your own. You must have edit access to the calendar.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 9:35 AM and 9:40 AM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 01, 2023 09:35:00'), new Date('Feb 01, 2023 09:40:00'))[0];

if (event) {
 // If an event exists within the given time frame, sets the event so that guests can invite
 // other guests.
 event.setGuestsCanInviteOthers(true);
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Tham số

TênLoạiMô tả
guestsCanInviteOthersBooleanxem khách có thể mời người khác không

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setGuestsCanModify(guestsCanModify)

Đặt xem khách có thể sửa đổi sự kiện hay không.

Tham số

TênLoạiMô tả
guestsCanModifyBooleanliệu khách có thể sửa đổi sự kiện hay không

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setGuestsCanSeeGuests(guestsCanSeeGuests)

Đặt xem khách có thể nhìn thấy khách khác không.

Tham số

TênLoạiMô tả
guestsCanSeeGuestsBooleanxem khách có thể nhìn thấy những người khác không

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setLocation(location)

Đặt địa điểm cho sự kiện.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 4:10 PM and 4:25 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 01, 2023 16:10:00'), new Date('Feb 01, 2023 16:25:00'))[0];

if (event) {
 // If an event exists within the given time frame, sets the location of the event to Noida.
 event.setLocation('Noida');
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Tham số

TênLoạiMô tả
locationStringvị trí mới

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setMyStatus(status)

Đặt trạng thái sự kiện (chẳng hạn như đang tham dự hoặc được mời) của người dùng hiệu quả.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for February 1st, 2023 that takes place
// between 4:10 PM and 4:25 PM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Feb 01, 2023 16:10:00'), new Date('Feb 01, 2023 16:25:00'))[0];

if (event) {
 // If an event exists within the given time frame, sets the event status for the current user
 to maybe.
 event.setMyStatus(CalendarApp.GuestStatus.MAYBE);
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Tham số

TênLoạiMô tả
statusGuestStatustrạng thái mới

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/calendar.readonly
  • https://www.google.com/calendar/feeds

setTag(key, value)

Đặt thẻ khoá/giá trị cho sự kiện để lưu trữ siêu dữ liệu tuỳ chỉnh.

Tham số

TênLoạiMô tả
keyStringkhoá thẻ
valueStringgiá trị thẻ

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setTime(startTime, endTime)

Đặt ngày và giờ cho thời điểm bắt đầu và kết thúc sự kiện. Áp dụng phương thức này sẽ thay đổi sự kiện cả ngày thành một sự kiện thông thường.

// Opens the calendar by its ID.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Declares a start time of 11:00 AM on February 20th, 2023 and an end time of 12:00 PM on
// February 20th, 2023.
const startTime = new Date('Feb 20,2023 11:00:00');
const endTime = new Date('Feb 20, 2023  12:00:00');

// Creates an all-day event on February 20th, 2023.
const event = calendar.createAllDayEvent('Meeting', new Date('Feb 20,2023'));

// Updates the all-day event to a regular event by setting a start and end time for the event.
event.setTime(startTime, endTime);

Tham số

TênLoạiMô tả
startTimeDatethời điểm bắt đầu mới của sự kiện
endTimeDatethời điểm kết thúc mới của sự kiện

Cầu thủ trả bóng

CalendarEvent — CalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setTitle(title)

Đặt tiêu đề cho sự kiện.

// Opens the calendar by its ID. You must have edit access to the calendar.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('abc123456@group.calendar.google.com');

// Gets the first event from the calendar for January 31st, 2023 that takes place
// between 9:05 AM and 9:15 AM.
// For an event series, use calendar.getEventSeriesById('abc123456@google.com');
// and replace the series ID with your own.
const event =
  calendar.getEvents(new Date('Jan 31, 2023 09:05:00'), new Date('Jan 31, 2023 09:15:00'))[0];

if (event) {
 // If an event exists within the given time frame, changes its title to Event1.
 event.setTitle('Event1');
} else {
 // If no event exists within the given time frame, logs that information to the console.
 console.log('No events exist for the specified range');
}

Tham số

TênLoạiMô tả
titleStringtiêu đề mới

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds

setVisibility(visibility)

Đặt chế độ hiển thị của sự kiện.

Tham số

TênLoạiMô tả
visibilityVisibility

Cầu thủ trả bóng

CalendarEventCalendarEvent này để tạo chuỗi

Ủy quyền

Những tập lệnh dùng phương thức này yêu cầu uỷ quyền với một hoặc nhiều phạm vi hoặc phạm vi thích hợp sau đây trong API REST liên quan:

  • https://www.googleapis.com/auth/calendar
  • https://www.google.com/calendar/feeds