It is working as expected.
When you use
Code: Select all
date_now="{getDate(), dateformat,hhmm}";
You have turn the current time into string, date_now = "0828";
When you add it
Code: Select all
min_added= addMinutes(date_now, 2);
Automagic can't add minutes to string "0828". It doesn't recognize "0828" as number. (using debug dialog, will show it as number, even though it is string). So it just uses its intelligence to guess if the string can be parsed to number. It is the same as using toNumber("0828") before the calculation and resolved into number 828. Since automagic by default count time in miliseconds, this means 828 miliseconds. When you add 2 minutes to it, that means 2 x 60000 miliseconds =
120000. Then
120000 + 828 =
120828. Correct right?
The same with
Code: Select all
min_added= addMinutes("{getDate(), dateformat,hhmm}",2);
Time has been turned to string before adding, will still give the same result.
Those above should have answered question number 2, 3, 4.
For question 1, date should be leave as it. just use
So to add the minutes, use the same as before. It will give correct result, since the data type of date_now still
date, not yet turned to string.
Code: Select all
min_added= addMinutes(date_now, 2);
If you still need to add, minus or manipulate the date, don't turn it to string or any dateformat first. Use it only at the last moment when you are ready to output the data (as toast message, widget or anything).
If possible just leave it as it. At the Notification on screen or widget, just use {date_now,dateformat,hhmm"} instead of just {date_now}. So you never turn it into any dateformat before output it anywhere.