Countdown
› Forums › Desktop Info › Countdown
This topic contains 7 replies, has 3 voices, and was last updated by J 6 days, 5 hours ago.

AuthorPosts

JeffI would like to do a countdown between boot time and an arbitrary time in the future (for example, the next 3am after 6 days, 23hr and 30 minutes have passed.)
Is it possible to do date math directly?
thanks
0 
Hi Jeff, DTI doesn’t do date math. Some kind of date math might be feasible but your particular example seems like a real edge case.
0 
The idea is to give users a countdown until their next forced reboot. Not so much an edge case as an innovative tool for something very common. 😉
In my organization it’s 7 days after your last reboot (lets users better control the timing of their updates while still being consistent). Specifically, 3am, after at least 6days, 23hours have passed.
Even just counting 7 days exactly would be fine if it was simple.
Thanks
0
ok. If we had access to the absolute seconds in the UPTIME item we could do a simple calculation to find the difference between 7 days and the uptime, which is 604800uptime or 6 days, 23 hours would be 601200uptime. Divide that by 86400 would give you the number of days remaining:
(601200uptime)/86400
That would give you a countdown in fraction of days, eg 6.5 days or 2.34 days etc.
0


You jogged my mentalbraining –
This gets the offset between 3am and the hour of the day the machine rebooted… then subtracts 2 minutes and saves it in seconds as %bootsec%
BOOTTIME=active:2,{{((((3%5)*3600)+((60%6)*60))120}},set:bootsec,hidden:1
THEN, this determines how long it will be until 3am, 7days from now, minus 2 minutes ( I’ll probably extend that to minus 30min to account for patching).
UPTIME=active:2,interval:60,display:{{Round(((7*(86400+%bootsec%))((%1*86400)+(%2*3600)+(%3*60)))/(24 * 3600))}} Days {{Round(FRAC(((7*86400+%bootsec%)((%1*86400)+(%2*3600)+(%3*60)))/(24 * 3600))*24)}} Hours {{Round(FRAC(FRAC(((7*86400+%bootsec%)((%1*86400)+(%2*3600)+(%3*60)))/(24 * 3600))*24)*60)}} Minutes
I’m sure I could do it with less code or make it pretty in a function, but it works.
Thanks for the spark.
 This reply was modified 6 days, 13 hours ago by J.
0 
Oops… couple mistakes fixed here. This works.
BOOTTIME=active:2,set:bootsec,display:{{((((2%5)*3600)+((60%6)*60))240)}},hidden:1
UPTIME=active:2,interval:60,display:{{Round((((7*86400)3600+(%bootsec%))((%1*86400)+(%2*3600)+(%3*60)))/(24*3600))}} Days {{Round(FRAC((((7*86400)3600+(%bootsec%))((%1*86400)+(%2*3600)+(%3*60)))/(24*3600))*24)}} Hours {{Round(FRAC(FRAC((((7*86400)3600+(%bootsec%))((%1*86400)+(%2*3600)+(%3*60)))/(24 * 3600))*24)*60)}} Minutes
 This reply was modified 6 days, 12 hours ago by J.
 This reply was modified 6 days, 12 hours ago by J.
1+
OMG does that work!?! I am impressed! 🙂
0
In principle, but I’m seeing it’s not quite perfect yet. I need to break it down and simplify. I’ll post the final.
0


AuthorPosts