Class Calendar

יומן

מייצג יומן שבבעלות המשתמש או שאליו הוא רשום.

Methods

שיטהסוג הערך המוחזרתיאור קצר
createAllDayEvent(title, date)CalendarEventיצירת אירוע חדש של יום שלם.
createAllDayEvent(title, startDate, endDate)CalendarEventיצירת אירוע חדש של יום שלם שיכול להימשך כמה ימים.
createAllDayEvent(title, startDate, endDate, options)CalendarEventיצירת אירוע חדש של יום שלם שיכול להימשך כמה ימים.
createAllDayEvent(title, date, options)CalendarEventיצירת אירוע חדש של יום שלם.
createAllDayEventSeries(title, startDate, recurrence)CalendarEventSeriesיצירת סדרה חדשה של אירועים של יום שלם.
createAllDayEventSeries(title, startDate, recurrence, options)CalendarEventSeriesיצירת סדרה חדשה של אירועים של יום שלם.
createEvent(title, startTime, endTime)CalendarEventייווצר אירוע חדש.
createEvent(title, startTime, endTime, options)CalendarEventייווצר אירוע חדש.
createEventFromDescription(description)CalendarEventיצירת אירוע מתיאור בפריסה גמישה.
createEventSeries(title, startTime, endTime, recurrence)CalendarEventSeriesיצירת סדרת אירועים חדשה.
createEventSeries(title, startTime, endTime, recurrence, options)CalendarEventSeriesיצירת סדרת אירועים חדשה.
deleteCalendar()voidהמחיקה של היומן היא סופית.
getColor()Stringהפונקציה מקבלת את הצבע של היומן.
getDescription()Stringהפונקציה מקבלת את התיאור של היומן.
getEventById(iCalId)CalendarEventהפונקציה מקבלת את האירוע עם המזהה שצוין.
getEventSeriesById(iCalId)CalendarEventSeriesהפונקציה מקבלת את סדרת האירועים עם המזהה הנתון.
getEvents(startTime, endTime)CalendarEvent[]הפונקציה מקבלת את כל האירועים שמתרחשים בטווח זמן נתון.
getEvents(startTime, endTime, options)CalendarEvent[]הפונקציה מקבלת את כל האירועים שמתרחשים בטווח זמן נתון ועומדים בקריטריונים שצוינו.
getEventsForDay(date)CalendarEvent[]הפונקציה מקבלת את כל האירועים שמתרחשים ביום נתון.
getEventsForDay(date, options)CalendarEvent[]הפונקציה מקבלת את כל האירועים שמתרחשים ביום נתון ועומדים בקריטריונים שצוינו.
getId()Stringהפונקציה מקבלת את המזהה של היומן.
getName()Stringהפונקציה מקבלת את שם היומן.
getTimeZone()Stringהפונקציה מקבלת את אזור הזמן של היומן.
isHidden()Booleanקובעת אם היומן מוסתר בממשק המשתמש.
isMyPrimaryCalendar()Booleanקובע אם היומן הוא היומן הראשי של המשתמש בפועל.
isOwnedByMe()Booleanקובע אם היומן בבעלותכם.
isSelected()Booleanקובעת אם האירועים ביומן יוצגו בממשק המשתמש.
setColor(color)Calendarהגדרת הצבע של היומן.
setDescription(description)Calendarהגדרת התיאור של יומן.
setHidden(hidden)Calendarקובעת אם היומן יוצג בממשק המשתמש.
setName(name)Calendarמגדיר את שם היומן.
setSelected(selected)Calendarקובעת אם האירועים ביומן יוצגו בממשק המשתמש.
setTimeZone(timeZone)Calendarהגדרת אזור הזמן של היומן.
unsubscribeFromCalendar()voidביטול ההרשמה של המשתמש ליומן.

מסמכים מפורטים

createAllDayEvent(title, date)

יצירת אירוע חדש של יום שלם.

// Creates an all-day event for the moon landing and logs the ID.
const event = CalendarApp.getDefaultCalendar().createAllDayEvent(
    'Apollo 11 Landing',
    new Date('July 20, 1969'),
);
Logger.log(`Event ID: ${event.getId()}`);

פרמטרים

שםסוגתיאור
titleStringשם האירוע.
dateDateתאריך האירוע (נעשה שימוש רק ביום, והשעה מתעלמת).

חזרה

CalendarEvent – האירוע שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

createAllDayEvent(title, startDate, endDate)

יצירת אירוע חדש של יום שלם שיכול להימשך כמה ימים.

// Creates an all-day event for the Woodstock festival (August 15th to 17th) and
// logs the ID.
const event = CalendarApp.getDefaultCalendar().createAllDayEvent(
    'Woodstock Festival',
    new Date('August 15, 1969'),
    new Date('August 18, 1969'),
);
Logger.log(`Event ID: ${event.getId()}`);

פרמטרים

שםסוגתיאור
titleStringשם האירוע.
startDateDateהתאריך שבו האירוע מתחיל (המערכת משתמשת רק ביום, והשעה מתעלמת).
endDateDateהתאריך שבו האירוע מסתיים (המערכת משתמשת רק ביום, והשעה מתעלמת). תאריך הסיום הוא בלעדי.

חזרה

CalendarEvent – האירוע שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

createAllDayEvent(title, startDate, endDate, options)

יצירת אירוע חדש של יום שלם שיכול להימשך כמה ימים.

// Creates an all-day event for the Woodstock festival (August 15th to 17th) and
// logs the ID.
const event = CalendarApp.getDefaultCalendar().createAllDayEvent(
    'Woodstock Festival',
    new Date('August 15, 1969'),
    new Date('August 18, 1969'),
    {location: 'Bethel, White Lake, New York, U.S.', sendInvites: true},
);
Logger.log(`Event ID: ${event.getId()}`);

פרמטרים

שםסוגתיאור
titleStringשם האירוע.
startDateDateהתאריך שבו האירוע מתחיל (המערכת משתמשת רק ביום, והשעה מתעלמת).
endDateDateהתאריך שבו האירוע מסתיים (המערכת משתמשת רק ביום, והשעה מתעלמת). תאריך הסיום הוא בלעדי.
optionsObjectאובייקט JavaScript שמציין פרמטרים מתקדמים, כפי שמפורטים בהמשך.

פרמטרים מתקדמים

שםסוגתיאור
descriptionStringתיאור האירוע.
locationStringהמיקום של האירוע.
guestsStringרשימה מופרדת בפסיקים של כתובות אימייל שצריך להוסיף כנוכחים.
sendInvitesBooleanהאם לשלוח הזמנות באימייל (ברירת המחדל: false).

חזרה

CalendarEvent – האירוע שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

createAllDayEvent(title, date, options)

יצירת אירוע חדש של יום שלם.

// Creates an all-day event for the moon landing and logs the ID.
const event = CalendarApp.getDefaultCalendar().createAllDayEvent(
    'Apollo 11 Landing',
    new Date('July 20, 1969'),
    {location: 'The Moon'},
);
Logger.log(`Event ID: ${event.getId()}`);

פרמטרים

שםסוגתיאור
titleStringשם האירוע.
dateDateתאריך האירוע (נעשה שימוש רק ביום, והשעה מתעלמת).
optionsObjectאובייקט JavaScript שמציין פרמטרים מתקדמים, כפי שמפורטים בהמשך.

פרמטרים מתקדמים

שםסוגתיאור
descriptionStringתיאור האירוע.
locationStringהמיקום של האירוע.
guestsStringרשימה מופרדת בפסיקים של כתובות אימייל שצריך להוסיף כנוכחים.
sendInvitesBooleanהאם לשלוח הזמנות באימייל (ברירת המחדל: false).

חזרה

CalendarEvent – האירוע שנוצר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

createAllDayEventSeries(title, startDate, recurrence)

יצירת סדרה חדשה של אירועים של יום שלם.

// Creates an event series for a no-meetings day, taking place every Wednesday
// in 2013.
const eventSeries = CalendarApp.getDefaultCalendar().createAllDayEventSeries(
    'No Meetings',
    new Date('January 2, 2013 03:00:00 PM EST'),
    CalendarApp.newRecurrence()
        .addWeeklyRule()
        .onlyOnWeekday(CalendarApp.Weekday.WEDNESDAY)
        .until(new Date('January 1, 2014')),
);
Logger.log(`Event Series ID: ${eventSeries.getId()}`);

פרמטרים

שםסוגתיאור
titleStringשם האירועים בסדרה
startDateDateהתאריך של האירוע הראשון בסדרה (נעשה שימוש רק ביום, השעה מתעלמת)
recurrenceEventRecurrenceהגדרות החזרה של סדרת האירועים

חזרה

CalendarEventSeries – סדרת האירועים שנוצרה

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

createAllDayEventSeries(title, startDate, recurrence, options)

יצירת סדרה חדשה של אירועים של יום שלם.

// Creates an event series for a no-meetings day, taking place every Wednesday
// in 2013.
const eventSeries = CalendarApp.getDefaultCalendar().createAllDayEventSeries(
    'No Meetings',
    new Date('January 2, 2013 03:00:00 PM EST'),
    CalendarApp.newRecurrence()
        .addWeeklyRule()
        .onlyOnWeekday(CalendarApp.Weekday.WEDNESDAY)
        .until(new Date('January 1, 2014')),
    {guests: 'everyone@example.com'},
);
Logger.log(`Event Series ID: ${eventSeries.getId()}`);

פרמטרים

שםסוגתיאור
titleStringשם האירועים בסדרה
startDateDateהתאריך של האירוע הראשון בסדרה (נעשה שימוש רק ביום, השעה מתעלמת)
recurrenceEventRecurrenceהגדרות החזרה של סדרת האירועים
optionsObjectאובייקט JavaScript שמציין פרמטרים מתקדמים, כפי שמפורטים בהמשך

פרמטרים מתקדמים

שםסוגתיאור
descriptionStringהתיאור של האירועים בסדרה
locationStringהמיקום של האירועים בסדרה
guestsStringרשימה של כתובות אימייל שמופרדות בפסיקים, שצריך להוסיף כאורחים לאירועים בסדרה
sendInvitesBooleanאם לשלוח הזמנות באימייל (ברירת המחדל: false)

חזרה

CalendarEventSeries – סדרת האירועים שנוצרה

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

createEvent(title, startTime, endTime)

ייווצר אירוע חדש.

אם לא מציינים אזור זמן, ערכי הזמן מפורשים בהקשר של אזור הזמן של הסקריפט, שעשוי להיות שונה מאזור הזמן של היומן.

// Creates an event for the moon landing and logs the ID.
const event = CalendarApp.getDefaultCalendar().createEvent(
    'Apollo 11 Landing',
    new Date('July 20, 1969 20:00:00 UTC'),
    new Date('July 21, 1969 21:00:00 UTC'),
);
Logger.log(`Event ID: ${event.getId()}`);

פרמטרים

שםסוגתיאור
titleStringשם האירוע
startTimeDateהתאריך והשעה שבהם האירוע מתחיל
endTimeDateהתאריך והשעה שבהם האירוע מסתיים

חזרה

CalendarEvent – האירוע שנוצר

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

createEvent(title, startTime, endTime, options)

ייווצר אירוע חדש.

אם לא מציינים אזור זמן, ערכי הזמן מפורשים בהקשר של אזור הזמן של הסקריפט, שעשוי להיות שונה מאזור הזמן של היומן.

// Creates an event for the moon landing and logs the ID.
const event = CalendarApp.getDefaultCalendar().createEvent(
    'Apollo 11 Landing',
    new Date('July 20, 1969 20:00:00 UTC'),
    new Date('July 20, 1969 21:00:00 UTC'),
    {location: 'The Moon'},
);
Logger.log(`Event ID: ${event.getId()}`);

פרמטרים

שםסוגתיאור
titleStringשם האירוע
startTimeDateהתאריך והשעה שבהם האירוע מתחיל
endTimeDateהתאריך והשעה שבהם האירוע מסתיים
optionsObjectאובייקט JavaScript שמציין פרמטרים מתקדמים, כפי שמפורטים בהמשך

פרמטרים מתקדמים

שםסוגתיאור
descriptionStringתיאור האירוע
locationStringהמיקום של האירוע
guestsStringרשימה מופרדת בפסיקים של כתובות אימייל שצריך להוסיף כנוכחים
sendInvitesBooleanאם לשלוח הזמנות באימייל (ברירת המחדל: false)

חזרה

CalendarEvent – האירוע שנוצר

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

createEventFromDescription(description)

יצירת אירוע מתיאור בפריסה גמישה.

התיאור צריך להיות באותו פורמט כמו התכונה הוספה מהירה בממשק המשתמש.

// Creates a new event and logs its ID.
const event = CalendarApp.getDefaultCalendar().createEventFromDescription(
    'Lunch with Mary, Friday at 1PM',
);
Logger.log(`Event ID: ${event.getId()}`);

פרמטרים

שםסוגתיאור
descriptionStringתיאור חופשי של האירוע

חזרה

CalendarEvent – האירוע שנוצר

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

createEventSeries(title, startTime, endTime, recurrence)

יצירת סדרת אירועים חדשה.

// Creates an event series for a team meeting, taking place every Tuesday and
// Thursday in 2013.
const eventSeries = CalendarApp.getDefaultCalendar().createEventSeries(
    'Team Meeting',
    new Date('January 1, 2013 03:00:00 PM EST'),
    new Date('January 1, 2013 04:00:00 PM EST'),
    CalendarApp.newRecurrence()
        .addWeeklyRule()
        .onlyOnWeekdays(
            [CalendarApp.Weekday.TUESDAY, CalendarApp.Weekday.THURSDAY])
        .until(new Date('January 1, 2014')),
);
Logger.log(`Event Series ID: ${eventSeries.getId()}`);

פרמטרים

שםסוגתיאור
titleStringשם האירועים בסדרה
startTimeDateהתאריך והשעה שבהם מתחיל האירוע הראשון בסדרה
endTimeDateהתאריך והשעה שבהם מסתיים האירוע הראשון בסדרה
recurrenceEventRecurrenceהגדרות החזרה של סדרת האירועים

חזרה

CalendarEventSeries – סדרת האירועים שנוצרה

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

createEventSeries(title, startTime, endTime, recurrence, options)

יצירת סדרת אירועים חדשה.

// Creates an event series for a team meeting, taking place every Tuesday and
// Thursday in 2013.
const eventSeries = CalendarApp.getDefaultCalendar().createEventSeries(
    'Team Meeting',
    new Date('January 1, 2013 03:00:00 PM EST'),
    new Date('January 1, 2013 04:00:00 PM EST'),
    CalendarApp.newRecurrence()
        .addWeeklyRule()
        .onlyOnWeekdays(
            [CalendarApp.Weekday.TUESDAY, CalendarApp.Weekday.THURSDAY])
        .until(new Date('January 1, 2014')),
    {location: 'Conference Room'},
);
Logger.log(`Event Series ID: ${eventSeries.getId()}`);

פרמטרים

שםסוגתיאור
titleStringשם האירועים בסדרה
startTimeDateהתאריך והשעה שבהם מתחיל האירוע הראשון בסדרה
endTimeDateהתאריך והשעה שבהם מסתיים האירוע הראשון בסדרה
recurrenceEventRecurrenceהגדרות החזרה של סדרת האירועים
optionsObjectאובייקט JavaScript שמציין פרמטרים מתקדמים, כפי שמפורטים בהמשך

פרמטרים מתקדמים

שםסוגתיאור
descriptionStringהתיאור של האירועים בסדרה
locationStringהמיקום של האירועים בסדרה
guestsStringרשימה של כתובות אימייל שמופרדות בפסיקים, שצריך להוסיף כאורחים לאירועים בסדרה
sendInvitesBooleanאם לשלוח הזמנות באימייל (ברירת המחדל: false)

חזרה

CalendarEventSeries – סדרת האירועים שנוצרה

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

deleteCalendar()

המחיקה של היומן היא סופית. משתמשים יכולים למחוק רק יומן שבבעלותם.

// Creates a calendar to delete.
const calendar = CalendarApp.createCalendar('Test');

// Deletes the 'Test' calendar permanently.
calendar.deleteCalendar();

זריקות

Error – אם מדובר ביומן שיובאו.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

getColor()

הפונקציה מקבלת את הצבע של היומן.

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

// Gets the color of the calendar and logs it to the console.
// For the default calendar, you can use CalendarApp.getColor() instead.
const calendarColor = calendar.getColor();
console.log(calendarColor);

חזרה

String – מחרוזת של צבע הקסדצימלי ("‎#rrggbb").

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

  • 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.
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com');

// Sets the description of the calendar to 'Test description.'
calendar.setDescription('Test description');

// Gets the description of the calendar and logs it to the console.
// For the default calendar, you can use CalendarApp.getDescription() instead.
const description = calendar.getDescription();
console.log(description);

חזרה

String – התיאור של היומן.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

getEventById(iCalId)

הפונקציה מקבלת את האירוע עם המזהה שצוין. אם הסדרה שייכת ליומן אחר מלבד יומן ברירת המחדל, צריך להפעיל את השיטה הזו מהיומן הזה. קריאה ל-CalendarApp.getEventById(iCalId) מחזירה רק אירוע ביומן ברירת המחדל.

יכול להיות שלאירועים שונים יהיה אותו מזהה אם הם חלק מסדרת אירועים. במקרה כזה, השיטה מחזירה רק את האירוע הראשון מהסדרה הזו.

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

// Creates an event for the moon landing.
const event = calendar.createEvent(
    'Apollo 11 Landing',
    new Date('July 20, 1969 20:05:00 UTC'),
    new Date('July 20, 1969 20:17:00 UTC'),
);

// Gets the calendar event ID and logs it to the console.
const iCalId = event.getId();
console.log(iCalId);

// Gets the event by its ID and logs the title of the event to the console.
// For the default calendar, you can use CalendarApp.getEventById(iCalId)
// instead.
const myEvent = calendar.getEventById(iCalId);
console.log(myEvent.getTitle());

פרמטרים

שםסוגתיאור
iCalIdStringמזהה האירוע.

חזרה

CalendarEvent – האירוע עם המזהה שצוין, או null אם האירוע לא קיים או שלמשתמש אין גישה אליו.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

getEventSeriesById(iCalId)

הפונקציה מקבלת את סדרת האירועים עם המזהה הנתון. אם המזהה שצוין הוא של CalendarEvent יחיד, CalendarEventSeries יוחזר עם אירוע יחיד בסדרה. הערה: אם סדרת האירועים שייכת ליומן אחר מלבד יומן ברירת המחדל, צריך להפעיל את השיטה הזו מ-Calendar. קריאה ישירה ל-CalendarApp.getEventSeriesById(iCalId) תחזיר רק סדרת אירועים שקיימת ביומן ברירת המחדל.

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

// Creates an event series for a daily team meeting from 1 PM to 2 PM.
// The series adds the daily event from January 1, 2023 through December 31,
// 2023.
const eventSeries = calendar.createEventSeries(
    'Team meeting',
    new Date('Jan 1, 2023 13:00:00'),
    new Date('Jan 1, 2023 14:00:00'),
    CalendarApp.newRecurrence().addDailyRule().until(new Date('Jan 1, 2024')),
);

// Gets the ID of the event series.
const iCalId = eventSeries.getId();

// Gets the event series by its ID and logs the series title to the console.
// For the default calendar, you can use CalendarApp.getEventSeriesById(iCalId)
// instead.
console.log(calendar.getEventSeriesById(iCalId).getTitle());

פרמטרים

שםסוגתיאור
iCalIdStringהמזהה של סדרת האירועים.

חזרה

CalendarEventSeries – הסדרה עם המזהה שצוין, או null אם הסדרה לא קיימת או שלמשתמש אין גישה אליה.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

getEvents(startTime, endTime)

הפונקציה מקבלת את כל האירועים שמתרחשים בטווח זמן נתון.

השיטה הזו מחזירה אירועים שמתחילים במהלך טווח הזמן שצוין, מסתיימים במהלך טווח הזמן או כוללים את טווח הזמן. אם לא מציינים אזור זמן, ערכים של זמן מפורשים בהקשר של אזור הזמן של הסקריפט, שעשוי להיות שונה מאזור הזמן של היומן.

// Determines how many events are happening in the next two hours.
const now = new Date();
const twoHoursFromNow = new Date(now.getTime() + 2 * 60 * 60 * 1000);
const events = CalendarApp.getDefaultCalendar().getEvents(now, twoHoursFromNow);
Logger.log(`Number of events: ${events.length}`);

פרמטרים

שםסוגתיאור
startTimeDateתחילת טווח הזמן
endTimeDateסוף טווח הזמן, לא כולל

חזרה

CalendarEvent[] — האירועים שמתרחשים בטווח הזמן

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

getEvents(startTime, endTime, options)

הפונקציה מקבלת את כל האירועים שמתרחשים בטווח זמן נתון ועומדים בקריטריונים שצוינו.

השיטה הזו מחזירה אירועים שמתחילים במהלך טווח הזמן שצוין, מסתיימים במהלך טווח הזמן או כוללים את טווח הזמן. אם לא מציינים אזור זמן, ערכים של זמן מפורשים בהקשר של אזור הזמן של הסקריפט, שעשוי להיות שונה מאזור הזמן של היומן.

חשוב לדעת שהסינון ב-author, ב-search או ב-statusFilters מתבצע אחרי החלת start ו-max. המשמעות היא שמספר האירועים שיוחזרו עשוי להיות קטן מ-max, גם אם אירועים נוספים עומדים בקריטריונים.

// Determines how many events are happening in the next two hours that contain
// the term "meeting".
const now = new Date();
const twoHoursFromNow = new Date(now.getTime() + 2 * 60 * 60 * 1000);
const events = CalendarApp.getDefaultCalendar().getEvents(
    now,
    twoHoursFromNow,
    {search: 'meeting'},
);
Logger.log(`Number of events: ${events.length}`);

פרמטרים

שםסוגתיאור
startTimeDateתחילת טווח הזמן
endTimeDateסוף טווח הזמן, לא כולל
optionsObjectאובייקט JavaScript שמציין פרמטרים מתקדמים, כפי שמפורטים בהמשך

פרמטרים מתקדמים

שםסוגתיאור
startIntegerהאינדקס של האירוע הראשון שיש להחזיר
maxIntegerמספר האירועים המקסימלי להחזרה
authorStringכתובת אימייל שמשמשת לסינון התוצאות לפי היוצר של האירוע
searchStringשאילתת חיפוש של טקסט מלא שמשמשת לסינון התוצאות
statusFilters[]GuestStatusמערך של סטטוסים המשמש לסינון תוצאות

חזרה

CalendarEvent[] – האירועים שמתרחשים בטווח הזמן ותואמים לקריטריונים

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

getEventsForDay(date)

הפונקציה מקבלת את כל האירועים שמתרחשים ביום נתון.

השיטה הזו מחזירה אירועים אם הם מתחילים במהלך היום הנתון, מסתיימים במהלך היום או כוללים את היום.

שימו לב: המערכת משתמשת רק בחלק של התאריך באובייקט Date, והיא מתעלמת מחלק השעה. התאריך מפורש כחצות באותו יום עד חצות ביום שלמחרת באזור הזמן של לוח השנה.

// Determines how many events are happening today.
const today = new Date();
const events = CalendarApp.getDefaultCalendar().getEventsForDay(today);
Logger.log(`Number of events: ${events.length}`);

פרמטרים

שםסוגתיאור
dateDateהתאריך שבו רוצים לאחזר אירועים (המערכת משתמשת רק ביום, והשעה מתעלמת)

חזרה

CalendarEvent[] – האירועים שמתרחשים בתאריך הנתון

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

getEventsForDay(date, options)

הפונקציה מקבלת את כל האירועים שמתרחשים ביום נתון ועומדים בקריטריונים שצוינו.

השיטה הזו מחזירה אירועים אם הם מתחילים במהלך היום הנתון, מסתיימים במהלך היום או כוללים את היום.

שימו לב: המערכת משתמשת רק בחלק של התאריך באובייקט Date, והיא מתעלמת מחלק השעה. התאריך מפורש כחצות באותו יום עד חצות ביום שלמחרת באזור הזמן של לוח השנה.

חשוב לדעת שהסינון ב-author, ב-search או ב-statusFilters מתבצע אחרי החלת start ו-max. המשמעות היא שמספר האירועים שיוחזרו עשוי להיות קטן מ-max, גם אם אירועים נוספים עומדים בקריטריונים.

// Determines how many events are happening today and contain the term
// "meeting".
const today = new Date();
const events = CalendarApp.getDefaultCalendar().getEventsForDay(today, {
  search: 'meeting',
});
Logger.log(`Number of events: ${events.length}`);

פרמטרים

שםסוגתיאור
dateDateהתאריך שבו רוצים לאחזר אירועים (המערכת משתמשת רק ביום, והשעה מתעלמת)
optionsObjectאפשרויות סינון מתקדמות

פרמטרים מתקדמים

שםסוגתיאור
startIntegerהאינדקס של האירוע הראשון שיש להחזיר
maxIntegerמספר האירועים המקסימלי להחזרה
authorStringכתובת אימייל שמשמשת לסינון התוצאות לפי היוצר של האירוע
searchStringשאילתת חיפוש של טקסט מלא שמשמשת לסינון התוצאות
statusFilters[]GuestStatusמערך של סטטוסים המשמש לסינון תוצאות

חזרה

CalendarEvent[] – האירועים שמתרחשים בתאריך הנתון ועומדים בקריטריונים

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

getId()

הפונקציה מקבלת את המזהה של היומן. המזהה של יומן ברירת המחדל של המשתמש הוא כתובת האימייל שלו.

// Opens the calendar by its ID.
// To get the user's default calendar, use CalendarApp.getDefaultCalendar().
// TODO(developer): Replace the ID with your own.
const calendar = CalendarApp.getCalendarById('222larabrown@gmail.com');

// Gets the ID of the calendar and logs it to the console.
const calendarId = calendar.getId();
console.log(calendarId);

חזרה

String – המזהה של היומן.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

getName()

הפונקציה מקבלת את שם היומן.

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

// Gets the name of the calendar and logs it to the console.
// For the default calendar, you can use CalendarApp.getName() instead.
const calendarName = calendar.getName();
console.log(calendarName);

חזרה

String — השם של היומן הזה.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

getTimeZone()

הפונקציה מקבלת את אזור הזמן של היומן.

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

// Gets the time zone of the calendar and logs it to the console.
// For the default calendar, you can use CalendarApp.getTimeZone() instead.
const timeZone = calendar.getTimeZone();
console.log(timeZone);

חזרה

String – אזור הזמן, שמצוין בפורמט ארוך (לדוגמה, 'America/New_York', כפי שמופיע ב-Joda.org).

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

isHidden()

קובעת אם היומן מוסתר בממשק המשתמש.

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

// Determines whether the calendar is hidden in the user interface and logs it
// to the console. For the default calendar, you can use CalendarApp.isHidden()
// instead.
const isHidden = calendar.isHidden();
console.log(isHidden);

חזרה

Booleantrue אם היומן מוסתר בממשק המשתמש, false אם הוא לא מוסתר.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

isMyPrimaryCalendar()

קובע אם היומן הוא היומן הראשי של המשתמש בפועל.

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

// Determines whether the calendar is the default calendar for
// the effective user and logs it to the console.
// For the default calendar, you can use CalendarApp.isMyPrimaryCalendar()
// instead.
const isMyPrimaryCalendar = calendar.isMyPrimaryCalendar();
console.log(isMyPrimaryCalendar);

חזרה

Booleantrue אם היומן הוא יומן ברירת המחדל של המשתמש בפועל, false אם לא.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

isOwnedByMe()

קובע אם היומן בבעלותכם.

// Gets a calendar by its ID. To get the user's default calendar, use
// CalendarApp.getDefault() instead.
// TODO(developer): Replace the ID with the calendar ID that you want to use.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Determines whether the calendar is owned by you and logs it.
console.log(calendar.isOwnedByMe());

חזרה

Booleantrue אם היומן בבעלותכם, false אם לא.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

isSelected()

קובעת אם האירועים ביומן יוצגו בממשק המשתמש.

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

// Determines whether the calendar's events are displayed in the user interface
// and logs it.
console.log(calendar.isSelected());

חזרה

Booleantrue אם האירועים ביומן מוצגים בממשק המשתמש, false אם לא

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

setColor(color)

הגדרת הצבע של היומן.

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

// Sets the color of the calendar to pink using the Calendar Color enum.
// For the default calendar, you can use CalendarApp.setColor() instead.
calendar.setColor(CalendarApp.Color.PINK);

פרמטרים

שםסוגתיאור
colorStringCalendarApp.Color או מחרוזת צבע הקסדצימלי (‎'#rrggbb').

חזרה

Calendar – היומן הזה לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

setDescription(description)

הגדרת התיאור של יומן.

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

// Sets the description of the calendar.
// TODO(developer): Update the string with the description that you want to use.
calendar.setDescription('Updated calendar description.');

פרמטרים

שםסוגתיאור
descriptionStringהתיאור של היומן הזה

חזרה

Calendar — היומן הזה לשרשור

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

setHidden(hidden)

קובעת אם היומן יוצג בממשק המשתמש.

פרמטרים

שםסוגתיאור
hiddenBooleantrue כדי להסתיר את היומן בממשק המשתמש, false כדי להציג אותו.

חזרה

Calendar — היומן הזה לשרשור

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

setName(name)

מגדיר את שם היומן.

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

// Sets the name of the calendar.
// TODO(developer): Update the string with the name that you want to use.
calendar.setName('Example calendar name');

פרמטרים

שםסוגתיאור
nameStringהשם החדש

חזרה

Calendar — היומן הזה לשרשור

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

setSelected(selected)

קובעת אם האירועים ביומן יוצגו בממשק המשתמש.

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

// Selects the calendar so that its events are displayed in the user interface.
// To unselect the calendar, set the parameter to false.
calendar.setSelected(true);

פרמטרים

שםסוגתיאור
selectedBooleantrue כדי להציג את האירועים ביומן בממשק המשתמש, false כדי להסתיר אותם.

חזרה

Calendar — היומן הזה לשרשור

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

setTimeZone(timeZone)

הגדרת אזור הזמן של היומן.

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

// Sets the time zone of the calendar to America/New York (US/Eastern) time.
calendar.setTimeZone('America/New_York');

פרמטרים

שםסוגתיאור
timeZoneStringאזור הזמן, שמצוין בפורמט ארוך (למשל 'America/New_York', כפי שמופיע ב-Joda.org).

חזרה

Calendar – היומן הזה לשרשור.

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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

unsubscribeFromCalendar()

ביטול ההרשמה של המשתמש ליומן. משתמשים לא יכולים לבטל את ההרשמה ליומנים שמופיעים ברשימה היומנים שלי. הם יכולים לבטל את ההרשמה ליומנים שמפורטים בקטע יומנים אחרים.

// Gets the calendar by its ID.
// TODO(developer): Replace the calendar ID with the calendar ID that you want
// to get.
const calendar = CalendarApp.getCalendarById(
    'abc123456@group.calendar.google.com',
);

// Unsubscribes the user from the calendar.
const result = calendar.unsubscribeFromCalendar();

זריקות

Error – אם מדובר ביומן בבעלותכם

אישור

סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחד או יותר מההיקפי הגישה הבאים, או עם היקפי גישה מתאימים מה-API ל-REST הקשור:

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