function blockOutCalendar() {
  /**
   * Helper function to get a the current date and set the time for the start and end of the event.
   * @param {number} hour The hour of the day for the new date.
   * @param {number} minutes The minutes of the day for the new date.
   * @return {Date} The new date.
   */
  function getDateAndHours(hour, minutes) {
    const date = new Date();
    date.setHours(hour);
    date.setMinutes(minutes);
    date.setSeconds(0);
    date.setMilliseconds(0);
    return date.toISOString();
  } 
  
  const event = {
    start: {dateTime: getDateAndHours(9,00)},
    end: {dateTime: getDateAndHours(17,00)},
    eventType: 'outOfOffice',
    summary: 'Out of office',
    outOfOfficeProperties: {
      autoDeclineMode: 'declineOnlyNewConflictingInvitations',
      declineMessage: 'Declined because I am taking a day of.',
    }
  }
  Calendar.Events.insert(event, 'primary');
}
Creates an out of office event in the user's Calendar.