回答編集履歴
2
a
test
CHANGED
@@ -4,11 +4,21 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
-
function
|
7
|
+
function q219287() {
|
8
8
|
|
9
|
-
const
|
9
|
+
const today = new Date();
|
10
10
|
|
11
|
-
|
11
|
+
const tomorrow = (new Date()).setDate(today.getDate() + 1);
|
12
|
+
|
13
|
+
[["きょう",today, getEvents(today)],["あした",tomorrow,getEvents(tomorrow)]].filter(function(e) { return e[2].length > 0;}).forEach(function(e){ sendToLine(e[0]+toTime(e[1])+'\n'+eventAsText(e[2]));});
|
14
|
+
|
15
|
+
}
|
16
|
+
|
17
|
+
function getEvents(thedate) {
|
18
|
+
|
19
|
+
return CalendarApp.getAllCalendars().map(function (cal) {
|
20
|
+
|
21
|
+
return [cal.getName(), getEventsStartsInTheDay(cal, thedate)];
|
12
22
|
|
13
23
|
}).filter(function (e) {
|
14
24
|
|
@@ -16,25 +26,17 @@
|
|
16
26
|
|
17
27
|
});
|
18
28
|
|
19
|
-
|
29
|
+
}
|
20
30
|
|
21
|
-
|
31
|
+
function eventAsText(events) {
|
22
32
|
|
23
|
-
} // quit if there's no events for today.
|
24
|
-
|
25
|
-
|
33
|
+
return events.map(function (e) {
|
26
34
|
|
27
35
|
return '◆ ' + e[0] + '\n' + e[1].map(eventToString).join('\n\n');
|
28
36
|
|
29
37
|
}).join('\n');
|
30
38
|
|
31
|
-
const head = toTime(new Date()) + "\n";
|
32
|
-
|
33
|
-
sendToLine(head + eventsAsText);
|
34
|
-
|
35
39
|
}
|
36
|
-
|
37
|
-
|
38
40
|
|
39
41
|
function sendToLine(text) {
|
40
42
|
|
@@ -64,15 +66,13 @@
|
|
64
66
|
|
65
67
|
|
66
68
|
|
67
|
-
function getEventsStartsT
|
69
|
+
function getEventsStartsInTheDay(calendar, thedate) {
|
68
70
|
|
69
|
-
const
|
71
|
+
const dateNum = thedate.getDate();
|
70
72
|
|
71
|
-
|
73
|
+
return calendar.getEventsForDay(thedate).filter(function (e) {
|
72
74
|
|
73
|
-
return calendar.getEventsForDay(today).filter(function (e) {
|
74
|
-
|
75
|
-
return e.getStartTime().getDate() ===
|
75
|
+
return e.getStartTime().getDate() === dateNum;
|
76
76
|
|
77
77
|
});
|
78
78
|
|
1
あ
test
CHANGED
@@ -1,100 +1,4 @@
|
|
1
|
-
今日中に終わるものだけにするやつ。直すならこうかな。
|
2
|
-
|
3
1
|
```javascripit
|
4
|
-
|
5
|
-
function main() {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
var calendars = CalendarApp.getAllCalendars();
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
var text = "";
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
for(i in calendars) {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
var calendar = calendars[i];
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
var events = calendar.getEventsForDay(new Date());
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
if( events.length > 0 ) {
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
text += "◆ " + calendar.getName() + "\n";
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
}
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
for(j in events) {
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
var event = events[j];
|
46
|
-
|
47
|
-
if(event.getEndTime().getDate() !== (new Date()).getDate()) {continue;}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
var title = event.getTitle();
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
var start = toTime(event.getStartTime());
|
56
|
-
|
57
|
-
var end = toTime(event.getEndTime());
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
text += start + ' - ' + end + "\n" + " " + title + '\n\n';
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
// if( events.length > 1 ) {
|
70
|
-
|
71
|
-
//
|
72
|
-
|
73
|
-
// sendToLine(text) += "\n";
|
74
|
-
|
75
|
-
//
|
76
|
-
|
77
|
-
// }
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
}
|
82
|
-
|
83
|
-
if(text === "") {return;}
|
84
|
-
|
85
|
-
sendToLine(Utilities.formatDate(new Date(), 'JST', 'yyyy/MM/dd') + "\n" + text);
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
}
|
90
|
-
|
91
|
-
```
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
合ってるか検証してないけど、私ならこうかく。
|
96
|
-
|
97
|
-
```javascript
|
98
2
|
|
99
3
|
const lineToken = "LINE コード";
|
100
4
|
|
@@ -104,7 +8,7 @@
|
|
104
8
|
|
105
9
|
const events = CalendarApp.getAllCalendars().map(function (cal) {
|
106
10
|
|
107
|
-
return [cal.getName(), getEvents
|
11
|
+
return [cal.getName(), getEventsStartsToday(cal)];
|
108
12
|
|
109
13
|
}).filter(function (e) {
|
110
14
|
|
@@ -160,15 +64,15 @@
|
|
160
64
|
|
161
65
|
|
162
66
|
|
163
|
-
function getEvents
|
67
|
+
function getEventsStartsToday(calendar) {
|
164
68
|
|
165
69
|
const today = new Date();
|
166
70
|
|
167
71
|
const thedate = today.getDate();
|
168
72
|
|
169
|
-
return calend
|
73
|
+
return calendar.getEventsForDay(today).filter(function (e) {
|
170
74
|
|
171
|
-
return e.get
|
75
|
+
return e.getStartTime().getDate() === thedate
|
172
76
|
|
173
77
|
});
|
174
78
|
|