Đại diện cho một sự kiện trên lịch.
Phương thức
Phương thức | Kiểu dữ liệu trả về | Mô tả ngắn |
---|---|---|
addEmailReminder(minutesBefore) | CalendarEvent | Thêm lời nhắc mới qua email vào sự kiện. |
addGuest(email) | CalendarEvent | Thêm khách vào sự kiện. |
addPopupReminder(minutesBefore) | CalendarEvent | Thêm thông báo bật lên mới vào sự kiện. |
addSmsReminder(minutesBefore) | CalendarEvent | Thêm lời nhắc SMS mới vào sự kiện. |
anyoneCanAddSelf() | Boolean | 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. |
deleteEvent() | void | Xoá sự kiện trên Lịch. |
deleteTag(key) | CalendarEvent | Xoá thẻ khoá/giá trị khỏi sự kiện. |
getAllDayEndDate() | Date | Lấy ngày kết thúc sự kiện cả ngày này trên lịch. |
getAllDayStartDate() | Date | Lấ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 những thẻ đã được đặt cho sự kiện. |
getColor() | String | Trả về màu của sự kiện trên lịch. |
getCreators() | String[] | Xem người tạo sự kiện. |
getDateCreated() | Date | Lấy ngày tạo sự kiện. |
getDescription() | String | Lấy nội dung mô tả về sự kiện. |
getEmailReminders() | Integer[] | Lấy giá trị phút cho tất cả lời nhắc qua email về sự kiện. |
getEndTime() | Date | Lấy ngày và giờ kết thúc sự kiện trên lịch này. |
getEventSeries() | CalendarEventSeries | Lấy chuỗi sự kiện định kỳ chứa sự kiện này. |
getGuestByEmail(email) | EventGuest | Mời khách qua địa chỉ email. |
getGuestList() | EventGuest[] | Nhận khách tham dự sự kiện, không bao gồm chủ sở hữu sự kiện. |
getGuestList(includeOwner) | EventGuest[] | Nhận khách tham dự sự kiện, có thể bao gồm cả chủ sở hữu sự kiện. |
getId() | String | Lấy iCalUID duy nhất của sự kiện. |
getLastUpdated() | Date | Lấy ngày cập nhật sự kiện lần gần đây nhất. |
getLocation() | String | Lấy vị trí của sự kiện. |
getMyStatus() | GuestStatus | Nhận 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 có hiệu lực. |
getOriginalCalendarId() | String | Lấy mã lịch nơi sự kiện này được tạo ban đầu. |
getPopupReminders() | Integer[] | Lấy giá trị phút cho tất cả lời nhắc bật lên về sự kiện. |
getSmsReminders() | Integer[] | Nhận giá trị phút cho tất cả lời nhắc qua SMS về sự kiện. |
getStartTime() | Date | Lấy ngày và giờ bắt đầu sự kiện trên lịch này. |
getTag(key) | String | Nhận giá trị thẻ của sự kiện. |
getTitle() | String | Lấy tiêu đề của sự kiện. |
getVisibility() | Visibility | Xem chế độ hiển thị của sự kiện. |
guestsCanInviteOthers() | Boolean | Xác định xem khách có thể mời những khách khác hay không. |
guestsCanModify() | Boolean | Xác định xem khách có thể chỉnh sửa sự kiện hay không. |
guestsCanSeeGuests() | Boolean | Xác định xem khách có thể nhìn thấy khách khác hay không. |
isAllDayEvent() | Boolean | Xác định xem đây có phải là sự kiện cả ngày hay không. |
isOwnedByMe() | Boolean | Xác định xem bạn có phải là chủ sở hữu sự kiện hay không. |
isRecurringEvent() | Boolean | Xác định xem sự kiện này có nằm trong một chuỗi sự kiện hay không. |
removeAllReminders() | CalendarEvent | Xoá tất cả lời nhắc khỏi sự kiện. |
removeGuest(email) | CalendarEvent | Xoá khách khỏi sự kiện. |
resetRemindersToDefault() | CalendarEvent | Đặt lại lời nhắc bằng chế độ 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 cho sự kiện. |
setAnyoneCanAddSelf(anyoneCanAddSelf) | CalendarEvent | Thiết lập liệu những khách không phải 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ả sự kiện. |
setGuestsCanInviteOthers(guestsCanInviteOthers) | CalendarEvent | Đặt xem khách có thể mời những khách khác hay không. |
setGuestsCanModify(guestsCanModify) | CalendarEvent | Đặt xem khách có thể sửa đổi sự kiện hay không. |
setGuestsCanSeeGuests(guestsCanSeeGuests) | CalendarEvent | Thiết lập liệu khách có thể nhìn thấy những khách khác hay không. |
setLocation(location) | CalendarEvent | Thiết lập vị trí của 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 có hiệu lực. |
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ờ bắt đầu và kết thúc sự kiện. |
setTitle(title) | CalendarEvent | Đặt tiêu đề của sự kiện. |
setVisibility(visibility) | CalendarEvent | Thiết lập 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 ít nhất 5 phút và tối đa là 4 tuần (40320 phút) trước 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'); // Adds an email notification for 15 minutes before the event. event.addEmailReminder(15);
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
minutesBefore | Integer | số phút trước sự kiện |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Gửi
Error
— nếu sự kiện có nhiều hơn 5 lời nhắc hoặc thời gian không nằm trong phạm vi pháp lý
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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); } }
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
email | String | Địa chỉ email của khách. |
Cầu thủ trả bóng
CalendarEvent
– CalendarEvent
này để tạo chuỗi.
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 xuất hiện trước sự kiện ít nhất 5 phút và tối đa là 4 tuần (40320 phút).
// 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);
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
minutesBefore | Integer | số phút trước sự kiện |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
addSmsReminder(minutesBefore)
Thêm lời nhắc SMS mới vào sự kiện. Lời nhắc phải ít nhất 5 phút và tối đa là 4 tuần (40320 phút) trước sự kiện.
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
minutesBefore | Integer | số phút trước sự kiện |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Gửi
Error
— nếu sự kiện có nhiều hơn 5 lời nhắc hoặc thời gian không nằm trong phạm vi pháp lý
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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
Boolean
– true
nếu khách không phải khách có thể tự thêm mình vào sự kiện; false
nếu không phải
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
deleteEvent()
Xoá 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
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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.
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
key | String | khoá thẻ |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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à một sự kiện cả ngày thì
phương thức này sẽ gửi ra ngoại lệ.) Date
được trả về đại diện cho nửa đêm vào đầ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 cả ngày này trên lịch
Gửi
Error
— nếu sự kiện này không phải là sự kiện cả ngày
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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à một sự kiện cả ngày thì phương thức này sẽ trả về một ngoại lệ.) Date
được trả về đại diện cho nửa đêm vào đầ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 cả ngày này trên lịch
Gửi
Error
— nếu sự kiện này không phải là sự kiện cả ngày
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 những 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
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getCreators()
Xem người tạo 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 người tạo sự kiện
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getDateCreated()
Lấy 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
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getDescription()
Lấy nội dung mô tả về 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
— mô tả
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 về sự kiện. Bạn phải có quyền chỉnh sửa 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 trong đó mỗi giá trị tương ứng với số phút trước sự kiện mà một lời nhắc kích hoạt
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 phải cả ngày, đây là thời điể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ì đây là nửa đêm đầu ngày sau khi sự kiện kết thúc theo múi giờ của lịch. Điều này cho phép so sánh ý nghĩa thời gian kết thúc cho tất cả các loại sự kiện; tuy nhiên, không nhất thiết phải giữ nguyên ngày trong năm ban đầu.
Đối với các sự kiện cả ngày, getAllDayEndDate()
hầu như luôn được gọi để ưu tiên 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
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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ỳ chứa sự kiện này. Bạn phải có quyền truy cập vào lịch. Một đối tượng CalendarEventSeries
được trả về ngay cả khi sự kiện này không thuộc về một chuỗi, để bạn có thể thêm các chế độ 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
một chuỗi sự kiện
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getGuestByEmail(email)
Mời 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()); }
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
email | String | địa chỉ của khách |
Cầu thủ trả bóng
EventGuest
– khách hoặc để trống nếu địa chỉ email không tương ứng với khách
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
getGuestList()
Nhận khách tham dự 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 mảng khách
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 tham dự sự kiện, có thể bao gồm cả 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()); }
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
includeOwner | Boolean | có bao gồm chủ sở hữu làm khách hay không |
Cầu thủ trả bóng
EventGuest[]
– một mảng khách
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 id
mà API Lịch phiên bản 3 và dịch vụ nâng cao của Lịch sử dụng không giống nhau và không thể 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ả cá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 có cùng 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
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getLastUpdated()
Lấy ngày cập nhật sự kiện lần gần đây 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
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getMyStatus()
Nhận 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 có hiệu lực. Luôn trả về GuestStatus.OWNER
nếu người dùng hiệu quả là chủ sở hữu của 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
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 nơi sự kiện này được tạo 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
— mã của lịch gốc
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 về 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 trong đó mỗi giá trị tương ứng với số phút trước sự kiện mà một lời nhắc kích hoạt
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
getSmsReminders()
Nhận giá trị phút cho tất cả lời nhắc qua SMS về sự kiện.
Cầu thủ trả bóng
Integer[]
– một mảng trong đó mỗi giá trị tương ứng với số phút trước sự kiện mà một lời nhắc kích hoạt
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 phải cả ngày, đây là thời điểm bắt đầu sự kiện được xác định. Đối với các sự kiện cả ngày chỉ lưu trữ ngày bắt đầu (không phải ngày và giờ), đây là nửa đêm của 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 ý nghĩa thời gian bắt đầu cho tất cả các loại sự kiện; tuy nhiên, phương pháp này không nhất thiết phải giữ nguyên ngày trong năm ban đầu chưa sửa đổi.
Đối với các sự kiện cả ngày, getAllDayStartDate()
hầu như luôn được gọi để ưu tiên 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 của sự kiện trên lịch này
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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.
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
key | String | khoá |
Cầu thủ trả bóng
String
– giá trị thẻ
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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ị chế độ hiển thị
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 những 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
Boolean
— true
nếu khách có thể mời người khác; false
nếu không
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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ể chỉnh sửa 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
Boolean
— true
nếu khách có thể chỉnh sửa sự kiện; false
nếu không thể
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 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 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
Boolean
— true
nếu khách có thể thấy các khách khác; false
nếu không thể
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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
Boolean
– true
nếu sự kiện diễn ra cả ngày; false
nếu không thể
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 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
Boolean
– true
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 phải
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 này có nằm trong 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
Boolean
– true
nếu sự kiện nằm trong một chuỗi sự kiện; false
nếu không
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.googleapis.com/auth/calendar.readonly
-
https://www.google.com/calendar/feeds
removeAllReminders()
Xoá 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
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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); } }
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
email | String | địa chỉ email của khách |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 chế độ 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
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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. Việc áp dụng phương thức này sẽ thay đổi một sự kiện thông thường 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'); }
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
date | Date | ngày của sự kiện (bỏ qua thời gian) |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setAllDayDates(startDate, endDate)
Đặt ngày cho sự kiện. Việc áp dụng phương thức này sẽ thay đổi một sự kiện thông thường thành một sự kiện cả ngà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 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'); }
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
startDate | Date | ngày bắt đầu sự kiện (bỏ qua thời gian) |
endDate | Date | ngày kết thúc sự kiện (bỏ qua thời gian) |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setAnyoneCanAddSelf(anyoneCanAddSelf)
Thiết lập liệu những khách không phải 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'); }
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
anyoneCanAddSelf | Boolean | liệu mọi người có thể mời chính mình hay không |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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'); }
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
color | String | Chỉ 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
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setDescription(description)
Đặt nội dung mô tả 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'); }
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
description | String | nội dung mô tả mới |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 những khách khác hay 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'); }
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
guestsCanInviteOthers | Boolean | liệu khách có thể mời người khác hay không |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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.
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
guestsCanModify | Boolean | khách có thể sửa đổi sự kiện hay không |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setGuestsCanSeeGuests(guestsCanSeeGuests)
Thiết lập liệu khách có thể nhìn thấy những khách khác hay không.
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
guestsCanSeeGuests | Boolean | khách có thể thấy những người khác hay không |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setLocation(location)
Thiết lập 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 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'); }
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
location | String | vị trí mới |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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 có hiệu lực.
// 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'); }
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
status | GuestStatus | trạng thái mới |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có 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.
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
key | String | khoá thẻ |
value | String | giá trị thẻ |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setTime(startTime, endTime)
Đặt ngày và giờ bắt đầu và kết thúc sự kiện. Việc áp dụng phương thức này sẽ thay đổi một 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);
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
startTime | Date | sự kiện mới bắt đầu |
endTime | Date | 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
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setTitle(title)
Đặt 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, 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'); }
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
title | String | tiêu đề mới |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds
setVisibility(visibility)
Thiết lập chế độ hiển thị của sự kiện.
Các tham số
Tên | Loại | Nội dung mô tả |
---|---|---|
visibility | Visibility |
Cầu thủ trả bóng
CalendarEvent
— CalendarEvent
này để tạo chuỗi
Ủy quyền
Các tập lệnh sử dụng phương thức này cần được 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 từ API REST có liên quan:
-
https://www.googleapis.com/auth/calendar
-
https://www.google.com/calendar/feeds