Ical / Get the tomorrow's first and last even

Hi,
I'd like to know how you would do to get the tomorrow first and the last events in a ical which I get with node-red-contrib-ical-events every day
Thx

Can you show us a sample of a days events that you are getting at the moment?

Hi Cymplecy,
Thank you for your answer.
My problem is not to get a result with the ical node but just to be able to get only the first and the last events tomorrow included in my calendar. I don't know how to setup the node just to get these events (tomorrow -> first event - last event).

The result is an array with this kind of information in each object of array :

[{"date":"4/1/22, 12:00 AM – 4/2/22, 12:00 AM","eventStart":"2022-03-31T20:00:00.000-04:00","eventEnd":"2022-04-01T20:00:00.000-04:00","summary":"homeoffice","duration":"PT24H","durationSeconds":86400,"rrule":{"_cache":{"all":false,"before":[],"after":[],"between":[]},"origOptions":{"dtstart":"2021-11-05T00:00:00.000Z","freq":2,"wkst":{"weekday":0},"byweekday":[{"weekday":4},{"weekday":0},{"weekday":1},{"weekday":2}]},"options":{"freq":2,"dtstart":"2021-11-05T00:00:00.000Z","interval":1,"wkst":0,"count":null,"until":null,"bysetpos":null,"bymonth":null,"bymonthday":[],"bynmonthday":[],"byyearday":null,"byweekno":null,"byweekday":[4,0,1,2],"bynweekday":null,"byhour":[0],"byminute":[0],"bysecond":[0],"byeaster":null}},"rruleText":"every week on Monday, Tuesday, Wednesday, Friday","uid":{"uid":"homeoffice-uuid","date":"1636070400000"},"isRecurring":true,"datetype":"date","allDay":true,"calendarName":"Calendrier Eleonore","originalEvent":{"type":"VEVENT","params":[],"start":"2021-11-05T00:00:00.000Z","datetype":"date","end":"2021-11-06T00:00:00.000Z","rrule":{"_cache":{"all":false,"before":[],"after":[],"between":[]},"origOptions":{"dtstart":"2021-11-05T00:00:00.000Z","freq":2,"wkst":{"weekday":0},"byweekday":[{"weekday":4},{"weekday":0},{"weekday":1},{"weekday":2}]},"options":{"freq":2,"dtstart":"2021-11-05T00:00:00.000Z","interval":1,"wkst":0,"count":null,"until":null,"bysetpos":null,"bymonth":null,"bymonthday":[],"bynmonthday":[],"byyearday":null,"byweekno":null,"byweekday":[4,0,1,2],"bynweekday":null,"byhour":[0],"byminute":[0],"bysecond":[0],"byeaster":null}},"dtstamp":"2022-02-05T11:32:46.000Z","uid":"homeoffice-uuid","created":"2021-11-05T11:48:02.000Z","description":"","lastmodified":"2021-11-17T09:47:02.000Z","location":"","sequence":"2","status":"CONFIRMED","summary":"homeoffice","transparency":"TRANSPARENT","duration":{"_isValid":true,"_milliseconds":86400000,"_days":0,"_months":0,"_data":{"milliseconds":0,"seconds":0,"minutes":0,"hours":0,"days":1,"months":0,"years":0},"_locale":{"_calendar":{"sameDay":"[Today at] LT","nextDay":"[Tomorrow at] LT","nextWeek":"dddd [at] LT","lastDay":"[Yesterday at] LT","lastWeek":"[Last] dddd [at] LT","sameElse":"L"},"_longDateFormat":{"LTS":"h:mm:ss A","LT":"h:mm A","L":"MM/DD/YYYY","LL":"MMMM D, YYYY","LLL":"MMMM D, YYYY h:mm A","LLLL":"dddd, MMMM D, YYYY h:mm A"},"_invalidDate":"Invalid date","_dayOfMonthOrdinalParse":{},"_relativeTime":{"future":"in %s","past":"%s ago","s":"a few seconds","ss":"%d seconds","m":"a minute","mm":"%d minutes","h":"an hour","hh":"%d hours","d":"a day","dd":"%d days","w":"a week","ww":"%d weeks","M":"a month","MM":"%d months","y":"a year","yy":"%d years"},"_months":["January","February","March","April","May","June","July","August","September","October","November","December"],"_monthsShort":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"_week":{"dow":0,"doy":6},"_weekdays":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"_weekdaysMin":["Su","Mo","Tu","We","Th","Fr","Sa"],"_weekdaysShort":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"_meridiemParse":{},"_eras":[{"since":"0001-01-01","until":null,"offset":1,"name":"Anno Domini","narrow":"AD","abbr":"AD"},{"since":"0000-12-31","until":null,"offset":1,"name":"Before Christ","narrow":"BC","abbr":"BC"}],"_abbr":"en","_config":{"calendar":{"sameDay":"[Today at] LT","nextDay":"[Tomorrow at] LT","nextWeek":"dddd [at] LT","lastDay":"[Yesterday at] LT","lastWeek":"[Last] dddd [at] LT","sameElse":"L"},"longDateFormat":{"LTS":"h:mm:ss A","LT":"h:mm A","L":"MM/DD/YYYY","LL":"MMMM D, YYYY","LLL":"MMMM D, YYYY h:mm A","LLLL":"dddd, MMMM D, YYYY h:mm A"},"invalidDate":"Invalid date","dayOfMonthOrdinalParse":{},"relativeTime":{"future":"in %s","past":"%s ago","s":"a few seconds","ss":"%d seconds","m":"a minute","mm":"%d minutes","h":"an hour","hh":"%d hours","d":"a day","dd":"%d days","w":"a week","ww":"%d weeks","M":"a month","MM":"%d months","y":"a year","yy":"%d years"},"months":["January","February","March","April","May","June","July","August","September","October","November","December"],"monthsShort":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"week":{"dow":0,"doy":6},"weekdays":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"weekdaysMin":["Su","Mo","Tu","We","Th","Fr","Sa"],"weekdaysShort":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"meridiemParse":{},"eras":[{"since":"0001-01-01","until":null,"offset":1,"name":"Anno Domini","narrow":"AD","abbr":"AD"},{"since":"0000-12-31","until":null,"offset":1,"name":"Before Christ","narrow":"BC","abbr":"BC"}],"abbr":"en"},"_dayOfMonthOrdinalParseLenient":{}}}},"countdown":{"days":0,"hours":1,"minutes":24,"seconds":55},"on":false},{"date":"4/1/22, 2:50 – 3:30 AM","eventStart":"2022-03-31T22:50:00.000-04:00","eventEnd":"2022-03-31T23:30:00.000-04:00","summary":"alarm","duration":"PT40M","durationSeconds":2400,"rrule":{"_cache":{"all":false,"before":[],"after":[],"between":[]},"origOptions":{"tzid":"Europe/Berlin","dtstart":"2020-01-21T04:50:00.000Z","freq":2,"byweekday":[{"weekday":4},{"weekday":0},{"weekday":3},{"weekday":1},{"weekday":2}]},"options":{"freq":2,"dtstart":"2020-01-21T04:50:00.000Z","interval":1,"wkst":0,"count":null,"until":null,"tzid":"Europe/Berlin","bysetpos":null,"bymonth":null,"bymonthday":[],"bynmonthday":[],"byyearday":null,"byweekno":null,"byweekday":[4,0,3,1,2],"bynweekday":null,"byhour":[4],"byminute":[50],"bysecond":[0],"byeaster":null}},"rruleText":"every weekday (~ approximate)","uid":{"uid":"alarm-uuid","date":"1579582200000"},"isRecurring":true,"datetype":"date","allDay":false,"calendarName":"Calendrier Eleonore","originalEvent":{"type":"VEVENT","params":[],"start":"2020-01-21T04:50:00.000Z","datetype":"date-time","end":"2020-01-21T05:30:00.000Z","rrule":{"_cache":{"all":false,"before":[],"after":[],"between":[]},"origOptions":{"tzid":"Europe/Berlin","dtstart":"2020-01-21T04:50:00.000Z","freq":2,"byweekday":[{"weekday":4},{"weekday":0},{"weekday":3},{"weekday":1},{"weekday":2}]},"options":{"freq":2,"dtstart":"2020-01-21T04:50:00.000Z","interval":1,"wkst":0,"count":null,"until":null,"tzid":"Europe/Berlin","bysetpos":null,"bymonth":null,"bymonthday":[],"bynmonthday":[],"byyearday":null,"byweekno":null,"byweekday":[4,0,3,1,2],"bynweekday":null,"byhour":[4],"byminute":[50],"bysecond":[0],"byeaster":null}},"dtstamp":"2022-02-05T11:32:46.000Z","uid":"alarm-uuid","created":"2020-01-20T17:09:22.000Z","description":"","lastmodified":"2020-01-24T18:15:06.000Z","location":"","sequence":"1","status":"CONFIRMED","summary":"alarm","transparency":"TRANSPARENT","duration":{"_isValid":true,"_milliseconds":2400000,"_days":0,"_months":0,"_data":{"milliseconds":0,"seconds":0,"minutes":40,"hours":0,"days":0,"months":0,"years":0},"_locale":{"_calendar":{"sameDay":"[Today at] LT","nextDay":"[Tomorrow at] LT","nextWeek":"dddd [at] LT","lastDay":"[Yesterday at] LT","lastWeek":"[Last] dddd [at] LT","sameElse":"L"},"_longDateFormat":{"LTS":"h:mm:ss A","LT":"h:mm A","L":"MM/DD/YYYY","LL":"MMMM D, YYYY","LLL":"MMMM D, YYYY h:mm A","LLLL":"dddd, MMMM D, YYYY h:mm A"},"_invalidDate":"Invalid date","_dayOfMonthOrdinalParse":{},"_relativeTime":{"future":"in %s","past":"%s ago","s":"a few seconds","ss":"%d seconds","m":"a minute","mm":"%d minutes","h":"an hour","hh":"%d hours","d":"a day","dd":"%d days","w":"a week","ww":"%d weeks","M":"a month","MM":"%d months","y":"a year","yy":"%d years"},"_months":["January","February","March","April","May","June","July","August","September","October","November","December"],"_monthsShort":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"_week":{"dow":0,"doy":6},"_weekdays":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"_weekdaysMin":["Su","Mo","Tu","We","Th","Fr","Sa"],"_weekdaysShort":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"_meridiemParse":{},"_eras":[{"since":"0001-01-01","until":null,"offset":1,"name":"Anno Domini","narrow":"AD","abbr":"AD"},{"since":"0000-12-31","until":null,"offset":1,"name":"Before Christ","narrow":"BC","abbr":"BC"}],"_abbr":"en","_config":{"calendar":{"sameDay":"[Today at] LT","nextDay":"[Tomorrow at] LT","nextWeek":"dddd [at] LT","lastDay":"[Yesterday at] LT","lastWeek":"[Last] dddd [at] LT","sameElse":"L"},"longDateFormat":{"LTS":"h:mm:ss A","LT":"h:mm A","L":"MM/DD/YYYY","LL":"MMMM D, YYYY","LLL":"MMMM D, YYYY h:mm A","LLLL":"dddd, MMMM D, YYYY h:mm A"},"invalidDate":"Invalid date","dayOfMonthOrdinalParse":{},"relativeTime":{"future":"in %s","past":"%s ago","s":"a few seconds","ss":"%d seconds","m":"a minute","mm":"%d minutes","h":"an hour","hh":"%d hours","d":"a day","dd":"%d days","w":"a week","ww":"%d weeks","M":"a month","MM":"%d months","y":"a year","yy":"%d years"},"months":["January","February","March","April","May","June","July","August","September","October","November","December"],"monthsShort":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"week":{"dow":0,"doy":6},"weekdays":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"weekdaysMin":["Su","Mo","Tu","We","Th","Fr","Sa"],"weekdaysShort":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"meridiemParse":{},"eras":[{"since":"0001-01-01","until":null,"offset":1,"name":"Anno Domini","narrow":"AD","abbr":"AD"},{"since":"0000-12-31","until":null,"offset":1,"name":"Before Christ","narrow":"BC","abbr":"BC"}],"abbr":"en"},"_dayOfMonthOrdinalParseLenient":{}}}},"countdown":{"days":0,"hours":4,"minutes":14,"seconds":55},"on":false},{"date":"4/1/22, 8:00 – 9:03 AM","eventStart":"2022-04-01T04:00:00.000-04:00","eventEnd":"2022-04-01T05:03:37.000-04:00","summary":"My Event","duration":"PT1H3M37S","durationSeconds":3817,"organizer":{"params":{"CN":"\"Organizer Name\"","EMAIL":"Organizer Email"},"val":"mailto:mailto:mail@example.com"},"rrule":{"_cache":{"all":false,"before":[],"after":[],"between":[]},"origOptions":{"tzid":"Etc/UTC","dtstart":"2021-01-15T08:00:00.000Z","freq":3},"options":{"freq":3,"dtstart":"2021-01-15T08:00:00.000Z","interval":1,"wkst":0,"count":null,"until":null,"tzid":"Etc/UTC","bysetpos":null,"bymonth":null,"bymonthday":[],"bynmonthday":[],"byyearday":null,"byweekno":null,"byweekday":null,"bynweekday":null,"byhour":[8],"byminute":[0],"bysecond":[0],"byeaster":null}},"rruleText":"every day (~ approximate)","uid":{"uid":"000-o8lmos@domain","date":"1610697600000"},"isRecurring":true,"datetype":"date","allDay":false,"calendarName":"Calendrier Eleonore","alarms":[{"trigger":"-P0DT0H10M0S","triggerParsed":"2022-04-01T07:50:00.000Z","action":"EMAIL","summary":"Alarm notification","description":"This is an event reminder","attendee":"mailto:fakemail@fakedomain.com"},{"trigger":"-P0DT0H20M0S","triggerParsed":"2022-04-01T07:40:00.000Z","action":"DISPLAY","description":"This is an event reminder"}],"originalEvent":{"type":"VEVENT","params":[],"uid":"000-o8lmos@domain","sequence":"0","dtstamp":"2021-01-15T14:52:55.000Z","start":"2021-01-15T08:00:00.000Z","datetype":"date-time","end":"2021-01-15T09:03:37.000Z","rrule":{"_cache":{"all":false,"before":[],"after":[],"between":[]},"origOptions":{"tzid":"Etc/UTC","dtstart":"2021-01-15T08:00:00.000Z","freq":3},"options":{"freq":3,"dtstart":"2021-01-15T08:00:00.000Z","interval":1,"wkst":0,"count":null,"until":null,"tzid":"Etc/UTC","bysetpos":null,"bymonth":null,"bymonthday":[],"bynmonthday":[],"byyearday":null,"byweekno":null,"byweekday":null,"bynweekday":null,"byhour":[8],"byminute":[0],"bysecond":[0],"byeaster":null}},"summary":"My Event","transparency":"OPAQUE","organizer":{"params":{"CN":"\"Organizer Name\"","EMAIL":"Organizer Email"},"val":"mailto:mailto:mail@example.com"},"MICROSOFT-CDO-BUSYSTATUS":"FREE","264602ef-afc8-4a08-bdab-19d3d5d133f4":{"type":"VALARM","params":[],"action":"EMAIL","description":"This is an event reminder","summary":"Alarm notification","attendee":"mailto:fakemail@fakedomain.com","trigger":"-P0DT0H10M0S","end":"2022-04-01T22:35:04.669Z"},"a93b8637-14ec-4eae-89c6-f3f021fb9ce4":{"type":"VALARM","params":[],"action":"DISPLAY","description":"This is an event reminder","trigger":"-P0DT0H20M0S","end":"2022-04-01T22:35:04.670Z"},"duration":{"_isValid":true,"_milliseconds":3817000,"_days":0,"_months":0,"_data":{"milliseconds":0,"seconds":37,"minutes":3,"hours":1,"days":0,"months":0,"years":0},"_locale":{"_calendar":{"sameDay":"[Today at] LT","nextDay":"[Tomorrow at] LT","nextWeek":"dddd [at] LT","lastDay":"[Yesterday at] LT","lastWeek":"[Last] dddd [at] LT","sameElse":"L"},"_longDateFormat":{"LTS":"h:mm:ss A","LT":"h:mm A","L":"MM/DD/YYYY","LL":"MMMM D, YYYY","LLL":"MMMM D, YYYY h:mm A","LLLL":"dddd, MMMM D, YYYY h:mm A"},"_invalidDate":"Invalid date","_dayOfMonthOrdinalParse":{},"_relativeTime":{"future":"in %s","past":"%s ago","s":"a few seconds","ss":"%d seconds","m":"a minute","mm":"%d minutes","h":"an hour","hh":"%d hours","d":"a day","dd":"%d days","w":"a week","ww":"%d weeks","M":"a month","MM":"%d months","y":"a year","yy":"%d years"},"_months":["January","February","March","April","May","June","July","August","September","October","November","December"],"_monthsShort":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"_week":{"dow":0,"doy":6},"_weekdays":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"_weekdaysMin":["Su","Mo","Tu","We","Th","Fr","Sa"],"_weekdaysShort":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"_meridiemParse":{},"_eras":[{"since":"0001-01-01","until":null,"offset":1,"name":"Anno Domini","narrow":"AD","abbr":"AD"},{"since":"0000-12-31","until":null,"offset":1,"name":"Before Christ","narrow":"BC","abbr":"BC"}],"_abbr":"en","_config":{"calendar":{"sameDay":"[Today at] LT","nextDay":"[Tomorrow at] LT","nextWeek":"dddd [at] LT","lastDay":"[Yesterday at] LT","lastWeek":"[Last] dddd [at] LT","sameElse":"L"},"longDateFormat":{"LTS":"h:mm:ss A","LT":"h:mm A","L":"MM/DD/YYYY","LL":"MMMM D, YYYY","LLL":"MMMM D, YYYY h:mm A","LLLL":"dddd, MMMM D, YYYY h:mm A"},"invalidDate":"Invalid date","dayOfMonthOrdinalParse":{},"relativeTime":{"future":"in %s","past":"%s ago","s":"a few seconds","ss":"%d seconds","m":"a minute","mm":"%d minutes","h":"an hour","hh":"%d hours","d":"a day","dd":"%d days","w":"a week","ww":"%d weeks","M":"a month","MM":"%d months","y":"a year","yy":"%d years"},"months":["January","February","March","April","May","June","July","August","September","October","November","December"],"monthsShort":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"week":{"dow":0,"doy":6},"weekdays":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"weekdaysMin":["Su","Mo","Tu","We","Th","Fr","Sa"],"weekdaysShort":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"meridiemParse":{},"eras":[{"since":"0001-01-01","until":null,"offset":1,"name":"Anno Domini","narrow":"AD","abbr":"AD"},{"since":"0000-12-31","until":null,"offset":1,"name":"Before Christ","narrow":"BC","abbr":"BC"}],"abbr":"en"},"_dayOfMonthOrdinalParseLenient":{}}}},"countdown":{"days":0,"hours":9,"minutes":24,"seconds":55},"on":false}]
'''c

Your sample array is already sorted by event start time, so a function node like this should work.

const first = msg.payload[0];
const last = msg.payload[msg.payload.length - 1];
msg.payload = [first, last];
return msg;

I expect someone else will show you a Jsonata expression to do it and someone else again a properly low code method :smiley:

Thank's Jbudd,

I'm going to try your solution but how can I setup the node to get only the events of tomorrow instead of all events since the current day ?

Can't you request just tomorow's events from ical? (Sorry, i have no idea who or what ical is).

I checked out again the node documentation and of course it was obvious... I found the way to get only the next day.
Thx !

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.