Class CalendarEvent

CalendarEvent

یک رویداد تقویم را نشان می دهد.

مواد و روش ها

روش نوع برگشت توضیح مختصر
addEmailReminder(minutesBefore) CalendarEvent یک یادآوری ایمیل جدید به رویداد اضافه می کند.
addGuest(email) CalendarEvent یک مهمان را به رویداد اضافه می کند.
addPopupReminder(minutesBefore) CalendarEvent یک اعلان پاپ آپ جدید به رویداد اضافه می کند.
addSmsReminder(minutesBefore) CalendarEvent یک یادآور SMS جدید به رویداد اضافه می کند.
anyoneCanAddSelf() Boolean تعیین می کند که آیا افراد می توانند خود را به عنوان مهمان به یک رویداد تقویم اضافه کنند یا خیر.
deleteEvent() void یک رویداد تقویم را حذف می کند.
deleteTag(key) CalendarEvent یک برچسب کلید/مقدار را از رویداد حذف می کند.
getAllDayEndDate() Date تاریخ پایان این رویداد تقویم تمام روز را دریافت می کند.
getAllDayStartDate() Date تاریخ شروع این رویداد تقویم تمام روز را دریافت می کند.
getAllTagKeys() String[] تمام کلیدهای برچسب هایی را که روی رویداد تنظیم شده اند دریافت می کند.
getColor() String رنگ رویداد تقویم را برمی‌گرداند.
getCreators() String[] سازندگان یک رویداد را دریافت می کند.
getDateCreated() Date تاریخ ایجاد رویداد را دریافت می کند.
getDescription() String شرح رویداد را دریافت می کند.
getEmailReminders() Integer[] مقادیر دقیقه را برای همه یادآوری‌های ایمیل رویداد دریافت می‌کند.
getEndTime() Date تاریخ و ساعت پایان این رویداد تقویم را دریافت می کند.
getEventSeries() CalendarEventSeries مجموعه ای از رویدادهای تکراری را که این رویداد به آن تعلق دارد دریافت می کند.
getGuestByEmail(email) EventGuest از طریق آدرس ایمیل یک مهمان می گیرد.
getGuestList() EventGuest[] مهمانان رویداد را می گیرد، بدون احتساب مالک رویداد.
getGuestList(includeOwner) EventGuest[] مهمانان رویداد، به طور بالقوه از جمله صاحبان رویداد را دریافت می کند.
getId() String iCalUID منحصر به فرد رویداد را دریافت می کند.
getLastUpdated() Date تاریخ آخرین به روز رسانی رویداد را دریافت می کند.
getLocation() String مکان رویداد را دریافت می کند.
getMyStatus() GuestStatus وضعیت رویداد (مانند حضور یا دعوت) کاربر مؤثر را دریافت می کند.
getOriginalCalendarId() String شناسه تقویمی که این رویداد در ابتدا در آنجا ایجاد شده است را دریافت کنید.
getPopupReminders() Integer[] مقادیر دقیقه را برای همه یادآورهای پاپ آپ رویداد دریافت می کند.
getSmsReminders() Integer[] مقادیر دقیقه را برای همه یادآورهای پیامک رویداد دریافت می کند.
getStartTime() Date تاریخ و ساعت شروع این رویداد تقویم را دریافت می کند.
getTag(key) String مقدار برچسب رویداد را دریافت می کند.
getTitle() String عنوان رویداد را دریافت می کند.
getVisibility() Visibility دید رویداد را دریافت می کند.
guestsCanInviteOthers() Boolean تعیین می کند که آیا مهمانان می توانند مهمانان دیگر را دعوت کنند یا خیر.
guestsCanModify() Boolean تعیین می کند که آیا مهمانان می توانند رویداد را تغییر دهند یا خیر.
guestsCanSeeGuests() Boolean تعیین می کند که آیا مهمانان می توانند مهمانان دیگر را ببینند یا خیر.
isAllDayEvent() Boolean تعیین می کند که آیا این یک رویداد تمام روز است.
isOwnedByMe() Boolean تعیین می کند که آیا شما مالک رویداد هستید یا خیر.
isRecurringEvent() Boolean تعیین می کند که آیا رویداد بخشی از یک مجموعه رویداد است.
removeAllReminders() CalendarEvent همه یادآوری ها را از رویداد حذف می کند.
removeGuest(email) CalendarEvent یک مهمان را از رویداد حذف می کند.
resetRemindersToDefault() CalendarEvent یادآوری ها را با استفاده از تنظیمات پیش فرض تقویم بازنشانی می کند.
setAllDayDate(date) CalendarEvent تاریخ رویداد را تعیین می کند.
setAllDayDates(startDate, endDate) CalendarEvent تاریخ های رویداد را تعیین می کند.
setAnyoneCanAddSelf(anyoneCanAddSelf) CalendarEvent تعیین می‌کند که افراد غیرمهمان بتوانند خود را به رویداد اضافه کنند یا خیر.
setColor(color) CalendarEvent رنگ رویداد تقویم را تنظیم می کند.
setDescription(description) CalendarEvent شرح رویداد را تنظیم می کند.
setGuestsCanInviteOthers(guestsCanInviteOthers) CalendarEvent تعیین می کند که آیا مهمانان می توانند مهمانان دیگر را دعوت کنند یا خیر.
setGuestsCanModify(guestsCanModify) CalendarEvent تعیین می کند که آیا مهمانان می توانند رویداد را تغییر دهند یا خیر.
setGuestsCanSeeGuests(guestsCanSeeGuests) CalendarEvent تعیین می کند که آیا مهمانان می توانند مهمانان دیگر را ببینند یا خیر.
setLocation(location) CalendarEvent مکان رویداد را تنظیم می کند.
setMyStatus(status) CalendarEvent وضعیت رویداد (مانند حضور یا دعوت) کاربر مؤثر را تنظیم می کند.
setTag(key, value) CalendarEvent یک برچسب کلید/مقدار روی رویداد برای ذخیره ابرداده های سفارشی تنظیم می کند.
setTime(startTime, endTime) CalendarEvent تاریخ و زمان شروع و پایان رویداد را تعیین می کند.
setTitle(title) CalendarEvent عنوان رویداد را تعیین می کند.
setVisibility(visibility) CalendarEvent نمایان بودن رویداد را تنظیم می کند.

مستندات دقیق

addEmailReminder(minutesBefore)

یک یادآوری ایمیل جدید به رویداد اضافه می کند. یادآوری باید حداقل 5 دقیقه و حداکثر 4 هفته (40320 دقیقه) قبل از رویداد باشد.

// 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);

مولفه های

نام تایپ کنید شرح
minutesBefore Integer تعداد دقیقه قبل از رویداد

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

پرتاب می کند

Error - اگر بیش از 5 یادآوری در مورد رویداد وجود داشته باشد یا زمان در محدوده قانونی نباشد

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

addGuest(email)

یک مهمان را به رویداد اضافه می کند.

// 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);
  }
}

مولفه های

نام تایپ کنید شرح
email String آدرس ایمیل مهمان.

برگشت

CalendarEvent - این CalendarEvent برای زنجیره‌بندی.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

addPopupReminder(minutesBefore)

یک اعلان پاپ آپ جدید به رویداد اضافه می کند. اعلان باید حداقل 5 دقیقه و حداکثر 4 هفته (40320 دقیقه) قبل از رویداد باشد.

// 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);

مولفه های

نام تایپ کنید شرح
minutesBefore Integer تعداد دقیقه قبل از رویداد

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

addSmsReminder(minutesBefore)

یک یادآور SMS جدید به رویداد اضافه می کند. یادآوری باید حداقل 5 دقیقه و حداکثر 4 هفته (40320 دقیقه) قبل از رویداد باشد.

مولفه های

نام تایپ کنید شرح
minutesBefore Integer تعداد دقیقه قبل از رویداد

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

پرتاب می کند

Error - اگر بیش از 5 یادآوری در مورد رویداد وجود داشته باشد یا زمان در محدوده قانونی نباشد

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

anyoneCanAddSelf()

تعیین می کند که آیا افراد می توانند خود را به عنوان مهمان به یک رویداد تقویم اضافه کنند یا خیر.

// 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());

برگشت

Boolean - true اگر غیر مهمانان بتوانند خود را به رویداد اضافه کنند. false اگر نه

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

deleteEvent()

یک رویداد تقویم را حذف می کند.

// 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();

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

deleteTag(key)

یک برچسب کلید/مقدار را از رویداد حذف می کند.

مولفه های

نام تایپ کنید شرح
key String کلید برچسب

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getAllDayEndDate()

تاریخ پایان این رویداد تقویم تمام روز را دریافت می کند. (اگر این یک رویداد تمام روز نیست، پس این روش یک استثنا ایجاد می کند.) Date برگشتی نشان دهنده نیمه شب در ابتدای روز پس از پایان رویداد در منطقه زمانی اسکریپت است. برای استفاده از منطقه زمانی تقویم به جای آن، 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);

برگشت

Date - تاریخ پایان این رویداد تقویم تمام روز

پرتاب می کند

Error - اگر این رویداد یک رویداد تمام روز نباشد

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getAllDayStartDate()

تاریخ شروع این رویداد تقویم تمام روز را دریافت می کند. (اگر این یک رویداد تمام روز نیست، پس این روش یک استثنا ایجاد می کند.) Date بازگشتی نشان دهنده نیمه شب در ابتدای روزی است که در آن رویداد در منطقه زمانی اسکریپت شروع می شود. برای استفاده از منطقه زمانی تقویم به جای آن، 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);

برگشت

Date - تاریخ شروع این رویداد تقویم تمام روز

پرتاب می کند

Error - اگر این رویداد یک رویداد تمام روز نباشد

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getAllTagKeys()

تمام کلیدهای برچسب هایی را که روی رویداد تنظیم شده اند دریافت می کند.

برگشت

String[] - آرایه ای از کلیدهای رشته ای

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getColor()

رنگ رویداد تقویم را برمی‌گرداند.

// 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);

برگشت

String - نمایش رشته رنگ رویداد، به عنوان یک شاخص (1-11) از مقادیر CalendarApp.EventColor .

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getCreators()

سازندگان یک رویداد را دریافت می کند.

// 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());

برگشت

String[] - آدرس ایمیل سازندگان رویداد

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getDateCreated()

تاریخ ایجاد رویداد را دریافت می کند. شما باید به تقویم دسترسی داشته باشید.

// 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');
}

برگشت

Date - تاریخ ایجاد

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getDescription()

شرح رویداد را دریافت می کند. شما باید دسترسی ویرایش به تقویم داشته باشید.

// 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');
}

برگشت

String - توضیحات

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getEmailReminders()

مقادیر دقیقه را برای همه یادآوری‌های ایمیل رویداد دریافت می‌کند. شما باید دسترسی ویرایش به تقویم داشته باشید.

// 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');
}

برگشت

Integer[] - آرایه‌ای که در آن هر مقدار با تعداد دقیقه‌های قبل از رویدادی که یادآوری راه‌اندازی می‌کند مطابقت دارد.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getEndTime()

تاریخ و ساعت پایان این رویداد تقویم را دریافت می کند. شما باید به تقویم دسترسی داشته باشید. برای رویدادهای غیر تمام روز، این لحظه زمانی است که در آن رویداد برای پایان تعریف شده است. برای رویدادهای تمام روز، که فقط تاریخ پایان را ذخیره می‌کنند (نه تاریخ و زمان)، این نیمه شب در ابتدای روز پس از پایان رویداد در منطقه زمانی تقویم است. این امکان مقایسه معنی‌دار زمان‌های پایانی را برای همه انواع رویدادها فراهم می‌کند. با این حال، لزوماً روز اول سال را بدون تغییر حفظ نمی کند.

برای رویدادهای تمام روز ، getAllDayEndDate() تقریباً همیشه باید در اولویت این روش فراخوانی شود.

// 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');
}

برگشت

Date - زمان پایان این رویداد تقویمی

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getEventSeries()

مجموعه ای از رویدادهای تکراری را که این رویداد به آن تعلق دارد دریافت می کند. شما باید به تقویم دسترسی داشته باشید. یک شیء CalendarEventSeries حتی اگر این رویداد به یک سری تعلق نداشته باشد، برگردانده می‌شود تا بتوانید تنظیمات تکراری جدیدی اضافه کنید.

// 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');
}

برگشت

CalendarEventSeries — مجموعه رویدادی که این رویداد به آن تعلق دارد، یا یک سری رویداد جدید اگر هنوز به یک سری تعلق ندارد

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getGuestByEmail(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());
}

مولفه های

نام تایپ کنید شرح
email String آدرس مهمان

برگشت

EventGuest - مهمان، یا اگر آدرس ایمیل با مهمان مطابقت نداشته باشد، خالی است

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getGuestList()

مهمانان رویداد را می گیرد، بدون احتساب مالک رویداد.

// 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());
}

برگشت

EventGuest[] - آرایه ای از مهمانان

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getGuestList(includeOwner)

مهمانان رویداد، به طور بالقوه از جمله صاحبان رویداد را دریافت می کند.

// 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());
}

مولفه های

نام تایپ کنید شرح
includeOwner Boolean آیا باید صاحبان را به عنوان میهمان شامل شود

برگشت

EventGuest[] - آرایه ای از مهمانان

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getId()

iCalUID منحصر به فرد رویداد را دریافت می کند. توجه داشته باشید که iCalUID و id رویداد مورد استفاده توسط Calendar v3 API و Calendar advanced یکسان نیستند و نمی توان آنها را به جای هم استفاده کرد. یک تفاوت در معنایی آنها این است که در رویدادهای تکرار شونده، همه رخدادهای یک رویداد دارای ids متفاوت هستند در حالی که همه آنها 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());

برگشت

String - iCalUID رویداد

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getLastUpdated()

تاریخ آخرین به روز رسانی رویداد را دریافت می کند.

// 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);

برگشت

Date - آخرین تاریخ به روز رسانی

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getLocation()

مکان رویداد را دریافت می کند.

// 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');
}

برگشت

String - محل رویداد

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getMyStatus()

وضعیت رویداد (مانند حضور یا دعوت) کاربر مؤثر را دریافت می کند. اگر کاربر مؤثر مالک رویداد باشد، همیشه GuestStatus.OWNER را برمی گرداند.

// 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');
}

برگشت

وضعیت GuestStatus - وضعیت

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getOriginalCalendarId()

شناسه تقویمی که این رویداد در ابتدا در آنجا ایجاد شده است را دریافت کنید.

// 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');
}

برگشت

String - شناسه تقویم اصلی

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getPopupReminders()

مقادیر دقیقه را برای همه یادآورهای پاپ آپ رویداد دریافت می کند.

  // 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');
}

برگشت

Integer[] - آرایه‌ای که در آن هر مقدار با تعداد دقیقه‌های قبل از رویدادی که یادآوری راه‌اندازی می‌کند مطابقت دارد.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getSmsReminders()

مقادیر دقیقه را برای همه یادآورهای پیامک رویداد دریافت می کند.

برگشت

Integer[] - آرایه‌ای که در آن هر مقدار با تعداد دقیقه‌های قبل از رویدادی که یادآوری راه‌اندازی می‌کند مطابقت دارد.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getStartTime()

تاریخ و ساعت شروع این رویداد تقویم را دریافت می کند. برای رویدادهای غیر تمام روز، این همان لحظه ای است که در آن رویداد برای شروع تعریف شده است. برای رویدادهای تمام روز، که فقط تاریخ شروع را ذخیره می‌کنند (نه تاریخ و زمان)، این نیمه شب در ابتدای روزی است که رویداد در منطقه زمانی تقویم شروع می‌شود. این امکان مقایسه معنی دار زمان شروع برای همه انواع رویدادها را فراهم می کند. با این حال، لزوماً روز اول سال را بدون تغییر حفظ نمی کند.

برای رویدادهای تمام روز ، getAllDayStartDate() تقریباً همیشه باید در اولویت این روش فراخوانی شود.

// 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);

برگشت

Date - زمان شروع این رویداد تقویمی

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getTag(key)

مقدار برچسب رویداد را دریافت می کند.

مولفه های

نام تایپ کنید شرح
key String کلید

برگشت

String - مقدار برچسب

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getTitle()

عنوان رویداد را دریافت می کند.

// 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');
}

برگشت

String - عنوان

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

getVisibility()

دید رویداد را دریافت می کند.

// 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');
}

برگشت

Visibility - مقدار دید

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

guestsCanInviteOthers()

تعیین می کند که آیا مهمانان می توانند مهمانان دیگر را دعوت کنند یا خیر.

// 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');
}

برگشت

Boolean - true اگر مهمانان بتوانند دیگران را دعوت کنند. false اگر نه

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

guestsCanModify()

تعیین می کند که آیا مهمانان می توانند رویداد را تغییر دهند یا خیر.

// 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');
}

برگشت

Boolean - true اگر مهمانان بتوانند رویداد را تغییر دهند. false اگر نه

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

guestsCanSeeGuests()

تعیین می کند که آیا مهمانان می توانند مهمانان دیگر را ببینند یا خیر.

// 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');
}

برگشت

Boolean - اگر مهمانان بتوانند مهمانان دیگر را ببینند true . false اگر نه

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

isAllDayEvent()

تعیین می کند که آیا این یک رویداد تمام روز است.

// 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());

برگشت

Boolean - اگر رویداد تمام روز باشد true . false اگر نه

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

isOwnedByMe()

تعیین می کند که آیا شما مالک رویداد هستید یا خیر.

// 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');
}

برگشت

Boolean - true اگر رویداد متعلق به کاربر مؤثر باشد. false اگر نه

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

isRecurringEvent()

تعیین می کند که آیا رویداد بخشی از یک مجموعه رویداد است.

// 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');
}

برگشت

Boolean - true اگر رویداد بخشی از یک سری رویداد باشد. false اگر نه

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

removeAllReminders()

همه یادآوری ها را از رویداد حذف می کند.

// 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');
}

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

removeGuest(email)

یک مهمان را از رویداد حذف می کند.

// 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);
  }
}

مولفه های

نام تایپ کنید شرح
email String آدرس ایمیل مهمان

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

resetRemindersToDefault()

یادآوری ها را با استفاده از تنظیمات پیش فرض تقویم بازنشانی می کند.

// 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');
}

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

setAllDayDate(date)

تاریخ رویداد را تعیین می کند. اعمال این روش یک رویداد معمولی را به یک رویداد تمام روز تبدیل می کند.

// 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');
}

مولفه های

نام تایپ کنید شرح
date Date تاریخ رویداد (زمان نادیده گرفته می شود)

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

setAllDayDates(startDate, endDate)

تاریخ های رویداد را تعیین می کند. اعمال این روش یک رویداد معمولی را به یک رویداد تمام روز تبدیل می کند.

// 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');
}

مولفه های

نام تایپ کنید شرح
startDate Date تاریخ شروع رویداد (زمان نادیده گرفته می شود)
endDate Date تاریخ پایان رویداد (زمان نادیده گرفته می شود)

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

setAnyoneCanAddSelf(anyoneCanAddSelf)

تعیین می‌کند که افراد غیرمهمان بتوانند خود را به رویداد اضافه کنند یا خیر.

// 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');
}

مولفه های

نام تایپ کنید شرح
anyoneCanAddSelf Boolean آیا کسی می تواند خود را دعوت کند

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

setColor(color)

رنگ رویداد تقویم را تنظیم می کند.

// 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');
}

مولفه های

نام تایپ کنید شرح
color String یک فهرست رنگ عدد صحیح به عنوان یک رشته، یا یک مقدار از CalendarApp.EventColor .

برگشت

CalendarEvent - این رویداد تقویم، برای زنجیره‌بندی.

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

setDescription(description)

شرح رویداد را تنظیم می کند.

// 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');
}

مولفه های

نام تایپ کنید شرح
description String توضیحات جدید

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

setGuestsCanInviteOthers(guestsCanInviteOthers)

تعیین می کند که آیا مهمانان می توانند مهمانان دیگر را دعوت کنند یا خیر.

// 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');
}

مولفه های

نام تایپ کنید شرح
guestsCanInviteOthers Boolean آیا مهمانان می توانند دیگران را دعوت کنند

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

setGuestsCanModify(guestsCanModify)

تعیین می کند که آیا مهمانان می توانند رویداد را تغییر دهند یا خیر.

مولفه های

نام تایپ کنید شرح
guestsCanModify Boolean آیا مهمانان می توانند رویداد را تغییر دهند

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

setGuestsCanSeeGuests(guestsCanSeeGuests)

تعیین می کند که آیا مهمانان می توانند مهمانان دیگر را ببینند یا خیر.

مولفه های

نام تایپ کنید شرح
guestsCanSeeGuests Boolean آیا مهمانان می توانند دیگران را ببینند

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

setLocation(location)

مکان رویداد را تنظیم می کند.

// 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');
}

مولفه های

نام تایپ کنید شرح
location String مکان جدید

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

setMyStatus(status)

وضعیت رویداد (مانند حضور یا دعوت) کاربر مؤثر را تنظیم می کند.

// 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');
}

مولفه های

نام تایپ کنید شرح
status GuestStatus وضعیت جدید

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

setTag(key, value)

یک برچسب کلید/مقدار روی رویداد برای ذخیره ابرداده های سفارشی تنظیم می کند.

مولفه های

نام تایپ کنید شرح
key String کلید برچسب
value String مقدار برچسب

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

setTime(startTime, endTime)

تاریخ و زمان شروع و پایان رویداد را تعیین می کند. اعمال این روش یک رویداد تمام روز را به یک رویداد معمولی تبدیل می کند.

// 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);

مولفه های

نام تایپ کنید شرح
startTime Date شروع جدید رویداد
endTime Date پایان جدید رویداد

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

setTitle(title)

عنوان رویداد را تعیین می کند.

// 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');
}

مولفه های

نام تایپ کنید شرح
title String عنوان جدید

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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

setVisibility(visibility)

نمایان بودن رویداد را تنظیم می کند.

مولفه های

نام تایپ کنید شرح
visibility Visibility

برگشت

CalendarEvent - این CalendarEvent برای زنجیر کردن

مجوز

اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر یا محدوده های مناسب از REST API مربوطه دارند:

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