IcalCalendar - presenting the calendar

Hi,

Sorry for my bad English.

I’m using the IcalCalendar app and would like to change the way data is displayed in a tag
“Today’s events in (calendar name)”

The tag outputs data like this: test 1; 21:00 to 22:00; test 2; 22:45 to 23:15

is it possible to edit the display of this data in the following format: test 1 (21:00-22:00), test 2 (22:45-23:15)?

You can convert stuff easy with the BetterLogicLibrary.
Or HomeyScript.

Give me a sec…

Well, like i said, you can do this in HomeyScript or in the Better Logic Library. Since BLL let’s you store in in variables directly and let you use the functions in other apps directly, im gonne explain it with the BLL app.

Install BLL, goto App Settings and create a function called iCalConverter. Place this inside the function:

function(value) {
  //let value = 'test 1; 21:00 to 22:00; test 2; 22:45 to 23:15';
  let matches = value.matchAll(/(.*?);\s(\d{1,2}:\d{1,2})\sto\s(\d{1,2}:\d{1,2});?\s?/gm);
  let result = "";

  for (match of matches) {
	if(result.length) result+=', '
	result += match[1] + ' (' + match[2] + '-' + match[3] + ')'; 
  }

  return result;
}

Now you can use this in any BLL supported app. If you only want a token/tag, use the Execution Expression (as Tag) card, and place this in it (replace the token with the iCalCalendar token and notice the double-quotes):

iCalConverter("[[token]]")

The result is what you want:

2 Likes

Thank you, thank you very much it works! :))

1 Like