Calendars are associated with the events, so it won’t be floating around without one. I’ve put together the script below for you. It should help you identify some specific details about your “ghost” event.
When you run it, you should get a screen showing you four options.
- Last week
- This week
- Next week
- This month
Hopefully one or two of those will help you track down your event. If it doesn’t cover the required period, hopefully it is straight forward enough for you to modify for a suitable date range (take a look at option 4 ).
When you tap on one of those it will write the list out to Scriptable’s console, noting the title of the calendar the event belongs to, the title of the event, if the event is all day and the date/times that go along with that type of event.
Here’s the script. Hope it helps.
//Build a menu and launch the event processing function with the range of events for the specified period.
let tblMenu = new UITable();
const intHeight = 30;
//Header
let rowHead = new UITableRow();
rowHead.isHeader = true;
rowHead.addText("Choose Period", "Tap on the period you would like to list events for. The results will be shown in the console.");
tblMenu.addRow(rowHead);
//Option 1 - last week
let rowData1 = new UITableRow();
rowData1.height = intHeight;
let btnData1 = rowData1.addButton("> Last Week", "");
btnData1.dismissOnTap = true;
btnData1.onTap = () =>
{
console.log("<< LAST WEEK >>");
CalendarEvent.lastWeek().then(procEvents, doErr);
}
tblMenu.addRow(rowData1);
//Option 2 - this week
let rowData2 = new UITableRow();
rowData2.height = intHeight;
let btnData2 = rowData2.addButton("> This Week", "");
btnData2.dismissOnTap = true;
btnData2.onTap = () =>
{
console.log("<< THIS WEEK >>");
CalendarEvent.thisWeek().then(procEvents, doErr);
}
tblMenu.addRow(rowData2);
//Option 3 - next week
let rowData3 = new UITableRow();
rowData3.height = intHeight;
let btnData3 = rowData3.addButton("> Next Week", "");
btnData3.dismissOnTap = true;
btnData3.onTap = () =>
{
console.log("<< NEXT WEEK >>");
CalendarEvent.nextWeek().then(procEvents, doErr);
}
tblMenu.addRow(rowData3);
//Option 4 - this month
let rowData4 = new UITableRow();
rowData4.height = intHeight;
let btnData4 = rowData4.addButton("> This Month", "");
btnData4.dismissOnTap = true;
btnData4.onTap = () =>
{
console.log("<< THIS MONTH >>");
let dtTemp = new Date(), intYear = dtTemp.getFullYear(), intMonth = dtTemp.getMonth();
let dtFrom = new Date(intYear, intMonth, 1, 0, 0, 0);
let dtTo = new Date(intYear, intMonth + 1, 0, 0,0,0);
CalendarEvent.between(dtFrom, dtTo).then(procEvents, doErr);
}
tblMenu.addRow(rowData4);
//Display the menu
await tblMenu.present();
//Process the events
function procEvents(events)
{
const tzUTC = { timeZone: "UTC" };
//Blank line
console.log("");
//write out a header
console.log("------------------------------------------------");
console.log("CALENDAR : EVENT : PERIOD");
console.log("------------------------------------------------");
//Loop through and output the details for each event
let intCount = 0;
for (intCount = 0; intCount < events.length; intCount++)
{
let event = events[intCount];
let strEvt = event.calendar.title;
strEvt += " : " + event.title;
if (event.isAllDay)
{
strEvt += " : All Day";
strEvt += " (" + event.startDate.toLocaleString("en-GB", tzUTC) + ")";
}
else
{
strEvt += " : In Day";
strEvt += " (" + event.startDate.toLocaleString("en-GB", tzUTC);
strEvt += " - " + event.endDate.toLocaleString("en-GB", tzUTC) + ")";
}
console.log(strEvt);
}
console.log("------------------------------------------------");
}
//Dump out any error information
function doErr(val)
{
console.log("ERROR");
console.error(val);
}