Calculate date of tomorrow

By The Way… what i have made now, is a fully automated alarmclock.
i add my schedule to apple agenda and with icalCalendar i can now know if i have to work tomorrow or not. before i go to sleep i will get an daily update via google hub. it tells me the temperature, how much power i have collected today, if i have to work or not, etc…
then, the next morning, my alarm will go off 1 hour before i have to start to work. only thing i have to do is adding the schedule.

this was needed coz icalcalender only checks the next event and collect its date. now i can verify if that date is tomorrow or not. as long as that date is not the same, i don’t have to work the next day :slight_smile:
At the time 4.30 i run that homeyscript to determine the next day date.

1 Like

image

Happy to have found your script for the day of the week, but it returns the wrong day for me.
This may be related to time zone? I am 1 hour later than Western Europe. Its after midnight and I just ran it, it still says Monday, but it is Tuesday already.

Was something deprecated? Any other idea?

It only works well after it is midnight in Londen I’m afraight.

1 Like

Thank you. I will do it the old fashioned way. :innocent:

image

1 Like

@Rrrr you can use the BetterLogic Library flowcard: format date.
Fill it with ddd or dddd and you will get the day, based on your timezone (can be configured or overruled).

1 Like

That is by far the most elegant way, thank you.

I read the BLL support pages in the app settings.
Can you calculate date of tomorrow?

1 Like

Well, yeah, but since date in this flowcard is just an argument (not coding), you will need the “Execute BLL Expression (as Tag)” card (or you would first need to set the date in another card).
Then place this in the expression:

date('dddd', new Date(new Date().setDate(new Date().getDate()+1)))

That’s it.



What you also could do, is create a function in the BLL App Settings called f.i. addDays, with this in it’s body:

function (days) {
  let d = new Date();
  return new Date(d.setDate(d.getDate()+days));
}

then write this in the Expressioncard:

date('dddd', addDays(1))

Thus, what you have now is:

and

Or, if you want know the day after tomorrow:

1 Like

@Arie_J_Godschalk :heartbeat:
Thank you for your complete answer and the options. Amazing to see how powerful BLL can be.

1 Like

And the developer

1 Like

Thanks!

And please note, all those codings can be used in any flowcard that supports bll coding, if you place it within {[ ]}
So, this coding can f.i. be used directly within a Google Service Speak flowcard, without the need for a ExpressionAsTag card.