Try this way
You can make use of DateTools
's EpochDifference
block to find difference in plain format.
Your blocks will cause an error in the UpdateDisplay procedure. Because TinyDb stores milliseconds and not instant.
I will test it again but at first look works in companion
Thanks for your reply. I tried this but get errors.
Argument to MakeInstant should have form MM/dd/YYYY hh:mm:ss, or MM/dd/YYYY or hh:mm
Clock1.SystemTime returns the current time in Milliseconds from 1970, a simple number.
Subtract two of those and you get interval in Ms.
Then divide by 1000 to get seconds
Divide by 60 to get minutes
...
This works! Thank you very much!
Learnt something new that "TinyDb stores milliseconds and not instant".
Thank you also @AGB for those additional explanations, but what if I want to do this not for seconds but for days?
For my app, I want the app to recognize how many days have passed since the last "save". If the last "save" was a second before midnight and I open the app again 1 second after midnight, I want that to count as one day later.
Thanks all!
Mark
Divide the seconds by 86400 to get "days"
But will that work even when less than a day has passed, as in the example I outlined above with the timestamps two seconds apart but on different days?
Basically, I want it to count one day even when just a second has passed, as long as midnight was passed.
In my opinion, it would not be logical. 1 day is 24 hours, so you can't say that something happened one day ago when it really happened 2 minutes ago. You can say that something happened yesterday without knowing exactly when. What will you display when 24 hours and 5 minutes have actually passed? Do you just want to display days without hours or minutes?
Difference by date:
Yes, I want the app to tell me how many days have passed in the way that a person would say something took place yesterday, or one day ago, even though it's just after midnight. In other words, how often has midnight been passed since the last date save event.
I have an example of how to do that with a date picker (see screenshot and app attached), but now I want it to do that when screen 1 is inialized, basically simulating someone pressing the date picker and immediately clicking OK to stick with the default option (which is today's date)
ChangeDateCalculateGapInDays.aia (3.1 KB)
I'll try this, thanks, really appreciate it
Mark
You could use TFormat extension by @Anke and calculate the duration in days, minutes, seconds
Yes, thanks Ria, might do that if this fails. Just waiting 13 minutes till it's midnight here to see if the blocks Patryk suggested do the trick for me
If not, I'll just go with the extension, which might be easier for this.
This is what I have now. I hope that equals the example Patryk suggested.
I works! Result attached in screenshot. I'll also post the entire blocks here for anyone looking at this in futere
Thanks all!
So, if I may ask, what do you see as the advantage of this compared to the one I built based on Patryk's advice? I mean the last one I posted, this one:
DaysPassed.aia (3.2 KB)
I have both that one and yours installed on my phone now to see if both perform as expected at the next midnight.
Thanks a lot!
Mark
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.