|
6 | 6 | */ |
7 | 7 | function createEventsFromSpreadsheet() { |
8 | 8 | // Open the spreadsheet and get the data. |
9 | | - var ss = SpreadsheetApp.openByUrl('ENTER SPREADSHEET URL HERE'); |
10 | | - var sheet = ss.getSheets()[0]; |
| 9 | + const ss = SpreadsheetApp.openByUrl('ENTER SPREADSHEET URL HERE'); |
| 10 | + const sheet = ss.getSheets()[0]; |
11 | 11 | /** @type {string[][]} */ |
12 | | - var data = sheet.getDataRange().getValues(); |
| 12 | + const data = sheet.getDataRange().getValues(); |
13 | 13 |
|
14 | 14 | // Remove any frozen rows from the data, since they contain headers. |
15 | 15 | data.splice(sheet.getFrozenRows()); |
16 | 16 |
|
17 | 17 | // Create an event for each row. |
18 | 18 | data.forEach(function(row) { |
19 | | - var title = row[0]; |
20 | | - var description = row[1]; |
21 | | - var emailsStr = row[2]; |
| 19 | + const title = row[0]; |
| 20 | + const description = row[1]; |
| 21 | + const emailsStr = row[2]; |
22 | 22 |
|
23 | 23 | // Split the emails into an array and remove extra whitespace. |
24 | | - var emails = emailsStr.split(',').map(function(email) { |
| 24 | + const emails = emailsStr.split(',').map(function(email) { |
25 | 25 | return email.trim(); |
26 | 26 | }); |
27 | 27 |
|
28 | | - var now = new Date(); |
| 28 | + const now = new Date(); |
29 | 29 | // Start the event at the next hour mark. |
30 | | - var start = new Date(now); |
| 30 | + const start = new Date(now); |
31 | 31 | start.setHours(start.getHours() + 1); |
32 | 32 | start.setMinutes(0); |
33 | 33 | start.setSeconds(0); |
34 | 34 | start.setMilliseconds(0); |
35 | 35 | // End the event after 30 minutes. |
36 | | - var end = new Date(start); |
| 36 | + const end = new Date(start); |
37 | 37 | end.setMinutes(end.getMinutes() + 30); |
38 | 38 |
|
39 | 39 | // Create the calendar event and invite the guests. |
40 | | - var event = CalendarApp.createEvent(title, start, end) |
| 40 | + const event = CalendarApp.createEvent(title, start, end) |
41 | 41 | .setDescription(description); |
42 | 42 | emails.forEach(function(email) { |
43 | 43 | event.addGuest(email); |
|
0 commit comments