Habpanel calculate date +1 to display waste calendar based on caldav

Dear all

I have been experimenting with the custom widget to display waste (Mülleimer) events based on caldav. The calendar stuff is working and I do have embedded that to a sitemap already. But I want to have that displayed in a more nicer way on the habpanel using animated GIF files I created (rotating waste bins with correct colour)

The below widget code does already work for ´today´ events. It picks up the next waste calendar event and works out depending on the start date and subject line of the event the corresponding animated git (yellow bag, paper, bio, waste)…

What my wife wants (and you know how important WAF is) is to give her in addition to the today is “xwz Müll” a second widget with a one day notice.

E.g. I do need to compare : if dateToday + 1 == CaldavDate then do this…

I have seen some references to a JavaScript called “moment.js” but I have no Idea how to reference/call this script from a widget and if I need to copy/install this first. If this is the right thing to do anyway….

Or is there perhaps an easier way to do this “date plus 1” calculating with build in widget functionality.
Would appreciate if somebody has got an idea of a correct syntax and give me a hit as I am not a java specialist at all…

Current script for “today” :

<div ng-if="(itemValue('dateToday')| date:'dd/MM/yyyy'=itemValue('CalDavDate')| date:'dd/MM/yyyy')">
			<img src="/static/muell/{{itemValue('CalDavMuelltonne')}}.gif" height="158" width="158"/>
      <h4>Heute ist {{itemValue('CalDavMuelltonne')}} Müll</h4>
<div ng-if="(itemValue('dateToday')| date:'dd/MM/yyyy'!=itemValue('CalDavDate')| date:'dd/MM/yyyy')">
  <h2>Heute keine Müllabfuhr!</h2> 
  <h4>Nächster Mülltermin: {{itemValue('CalDavDate') | date:'dd/MM/yyyy'}}</h4> 
	<h3>Nächster Müll ist: {{itemValue('CalDavMuelltonne')}}</h3>


Ok …

in the absence of answers I managed to implement a workaround. Created a DateTomorow item and when the dateToday is changing the rule that is executed as well calculates the DateTormorrow…

code line item : dateTomorrow.postUpdate(now.plusDays(1).toString)

By doing this I don’t need to calculate tomorrow in the habpanel template anymore but can simply reference the DateTomorrow item value…
This works but I still want to know how to calculate with AngularJS on the habpanel template. So if anybody got an idea please reply


1 Like