Results 1 to 4 of 4

Thread: Display Girder Uptime

  1. #1
    Join Date
    May 2004
    Location
    Dallas, TX
    Posts
    1,125

    Default Display Girder Uptime

    Found part of this somewhere on the board. Modified it some to make it more user friendly.

    Code:
    local seconds = win.GetElapsedSeconds ()
    local hour = string.format("%02.f", math.floor(seconds / 3600))
    local min = string.format("%02.f", math.floor(seconds / 60 - (hour * 60)))
    local sec = string.format("%02.f", math.floor(seconds - hour * 3600 - min * 60))
    local uptime = string.format('Girder has been running for %d hours %d minutes and %d seconds', hour, min, sec)
    print (uptime)
    Will display something similar to: Girder has been running for 0 hours 9 minutes and 36 seconds
    Rick

    Girder 6.0 - Elk M1 Gold - JRMC 11.1 w/ M-Audio Delta 410 - NetRemote - BlueIris DVR
    Girder 6 Plugins - Elk M1/EZ8, Pushover Connector and more on the way.


    Visit My Showcase

  2. #2
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    Hmm... that shouldn't work!

    Not using %d in the string.format at least. %s would be fine and would retain the formatting.
    --Rob

  3. #3
    Join Date
    Nov 2005
    Location
    Redditch, UK
    Posts
    957

    Default

    It formats it differently Rob...

    Using %d...
    Girder has been running for 1 hours 57 minutes and 1 seconds

    Using %s..
    Girder has been running for 01 hours 59 minutes and 03 seconds


    %s includes a preceeding 0 if needed it seems where %d doesn't.
    - John H
    * PROMIXIAN TO THE CORE! * (NetRemote2WholeHomePro + Girder5WholeHomePro + USB-UIRT + Touchscreens + WirelessControlSystems + ANNA) == AutomationHeaven
    - "IthinkI'mgoingtobantheuseofthespacebarinfuture..."

  4. #4
    Join Date
    May 2004
    Location
    Cardigan, UK
    Posts
    9,278

    Default

    That's what I would have expected since harleydude was already converting to a string using the "%02.f"

    Presumably what is happening is that the Lua runtime (or maybe the standard C runtime) is converting back to numeric form and then using that for the output.
    --Rob

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •