forked from teachduttonteach/GSuiteObjects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calendar.gs
35 lines (31 loc) · 1.15 KB
/
Calendar.gs
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
var Calendar = function(id) {
this.id = id;
this.ONE_DAY = 24*60*60*1000;
this.dateToday = new Date();
this.endDate = new Date();
this.upcomingEventObjects = [];
var getUpcomingEvents = function(daysToLookAhead) {
this.endDate.setMilliseconds(this.dateToday.getMilliseconds() + (daysToLookAhead * this.ONE_DAY));
var upcomingEvents = CalendarApp.getCalendarById(this.id).getEvents(this.dateToday, this.endDate);
for (var event in upcomingEvents.length) {
this.upcomingEventObjects.push(new CalendarEvent(event));
}
return this.upcomingEventObjects;
};
}
var CalendarEvent = function(event) {
this.event = event;
this.date = event.getEndTime();
this.date.setUTCDate(this.date.getUTCDate() - 1);
this.date.setMilliseconds(this.date.getMilliseconds() - 1);
this.month = event.getMonth() + 1;
this.title = event.getTitle();
var getDate = function(order, dateDelim, titleDelim) {
var dateString = titleDelim + this.title;
if (order == "MD") {
return this.month + dateDelim + this.date + dateString;
} else if (order == "DM") {
return this.date + dateDelim + this.month + dateString;
}
};
}