-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calendar.txt
44 lines (29 loc) · 1.15 KB
/
Calendar.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function scheduleShifts() {
var spreadsheet = SpreadsheetApp.getActiveSheet();
var eventCal = CalendarApp.getCalendarById("[email protected]");
var signups = spreadsheet.getRange(4, 5, 9, 3).getValues()
var signupsFiltered = [];
var j = 0;
for (var i = 0; i < signups.length; i++) {
Logger.log(signups[i][0] + typeof signups[i][1]);
Logger.log(signups[i][1] + typeof signups[i][1]);
if(typeof signups[i][1] === "object"){
signupsFiltered[j] = signups[i];
j++;
} else if(typeof signups[i][2] === "object"){
signupsFiltered[j] = signups[i];
j++;
}
}
Logger.log(signups[0])
Logger.log(signupsFiltered);
Logger.log(signupsFiltered.length);
Logger.log(signups.length);
for (x = 0; x < signupsFiltered.length; x++) {
var shift = signupsFiltered[x];
var manager = shift[0];
var vacDate = (typeof shift[1] === "string") ? shift[2] : shift[1];
Logger.log('Creating event for user: '+ manager +' on date: ' + vacDate);
eventCal.createAllDayEvent(manager + ' ' + 'has a day off!', vacDate)
}
}