MCPcopy Create free account
hub / github.com/ajatkj/scriptable / calendarText

Function calendarText

LSWeather.js:1302–1319  ·  view source on GitHub ↗
(calendarData)

Source from the content-addressed store, hash-verified

1300FUNCTION calendarText
1301------------------------------------------------------------------*/
1302function calendarText(calendarData) {
1303 const events = calendarData.pEventsTodayCount + calendarData.wEventsTodayCount;
1304 const allDayEvents = calendarData.pEventsTodayAllDayCount + calendarData.wEventsTodayAllDayCount;
1305 if (events == 0 && allDayEvents == 0){
1306 text = `Your day is clear.`;
1307 } else if (events == 0 && allDayEvents > 0) {
1308 text = `You've got ${allDayEvents} all day event(s) today.`;
1309 } else if (events > 0 && allDayEvents == 0) {
1310 text = `You've got ${events} event(s) today.`;
1311 } else {
1312 text = `You've got ${events} event(s) and ${allDayEvents} all day event(s) today.`;
1313 }
1314 let wrapText = (s, w) => s.replace(
1315 new RegExp(`(?![^\\n]{1,${w}}$)([^\\n]{1,${w}})\\s`, 'g'), '$1\n'
1316 );
1317 const text0 = wrapText(text,50);
1318 return text0;
1319}
1320/*------------------------------------------------------------------
1321FUNCTION checkUpdates
1322------------------------------------------------------------------*/

Callers

nothing calls this directly

Calls 1

wrapTextFunction · 0.70

Tested by

no test coverage detected