Countdown

Forums Desktop Info Countdown

This topic contains 7 replies, has 3 voices, and was last updated by Avatar J 6 days, 5 hours ago.

  • Author
    Posts
  • #1934 Reply
    Avatar
    Jeff

    I 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
  • #1936 Reply
    Glenn
    Glenn
    Keymaster

    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
  • #1943 Reply
    Avatar
    J
    Participant

    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
    • #1944 Reply
      Glenn
      Glenn
      Keymaster

      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 604800-uptime or 6 days, 23 hours would be 601200-uptime. Divide that by 86400 would give you the number of days remaining:

      (601200-uptime)/86400

      That would give you a countdown in fraction of days, eg 6.5 days or 2.34 days etc.

      0
  • #1946 Reply
    Avatar
    J
    Participant

    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, 12 hours ago by Avatar J.
    0
  • #1948 Reply
    Avatar
    J
    Participant

    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 Avatar J.
    • This reply was modified 6 days, 12 hours ago by Avatar J.
    1+
    • #1951 Reply
      Glenn
      Glenn
      Keymaster

      OMG does that work!?! I am impressed! 🙂

      0
      • #1952 Reply
        Avatar
        J
        Participant

        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
Reply To: Countdown
Your information:




Cancel
Do NOT follow this link or you will be banned from the site!