Was able to add the events results to the clipboard by following @sylumer code to post the resulting string to the clipboard.
Here is my modified version of @tf2 script <thank you!>
I can’t figure out how to completely eliminate the date from the first line - but I can delete it manually:
// script to get all events for
// all calendars for the next
// day, and add to a new draft
// by tf2
// get all calendars
let cals = Calendar.getAllCalendars();
// set a header string to hold
// the result
aDate = new Date();
aStr = aDate.getFullYear()+'-' + (pad2(aDate.getMonth()+1)) + '-'+ pad2(aDate.getDate());
result = "";
result += aStr + "\n";
// cycle thru calendars
for (let cal of cals) {
if (cal) {
// set today & tomorrow
let today = new Date();
let tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 2);
// get all events
let events = cal.events(today, tomorrow);
// cycle thru each event
for (let event of events) {
// get start date
let start = event.startDate;
// get hour, minutes
let st_hour = start.getHours();
let st_min = pad2(start.getMinutes());
// add to result
result += st_hour+":"+st_min+" ";
result += event.title;
result += "\n";
}
}
}
let d = new Draft();
d.content = result;
app.setClipboard(result);
console.log(result);
d.update();
// function to ensure minutes
// are two digits; from
// https://electrictoolbox.com/pad-number-two-digits-javascript/
function pad2(number) {
return (number < 10 ? '0' : '') + number
}