News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.

Post Reply  Post Thread 
converting seconds to %H:%M:%S
Author Message
Senior Member

Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
converting seconds to %H:%M:%S

Maybe this has already been asked? I don't recall.
It seems like there's something wrong here...when I attempt to use to convert seconds into hours:minutes:seconds, the minutes and seconds work, but hours always displays 19 instead of 00.

The first button gets the current Posix time string.
The second button gets a new time string (assuming you paused after clicking the first button), subtracts the first time string from that, and then is supposed to convert the difference into %T format (a.k.a. %H:%M:%S). That conversion is where my problem looks like this should have been easy.

#!/usr/bin/env murgaLua

win = fltk:Fl_Window(400, 300, ", os.time()")

start_button = fltk:Fl_Button(10, 10, 200, 25, "start")
starttime_display = fltk:Fl_Box(220, 10, 200, 25, "start time")
    starttime = os.time()
    endtime_display:label("end time")

end_button = fltk:Fl_Button(10, 40, 200, 25, "stop")
endtime_display = fltk:Fl_Box(220, 40, 200, 25, "end time")
    endtime = os.time()
    elapsed = endtime - starttime
    elapsed_display:label("%T", elapsed))
--    elapsed_display:label("%H:%M:%S", elapsed))

elapsed_display = fltk:Fl_Box(220, 80, 200, 200, "time elapsed")


Trying to be better at using whitespace...even though it adds a few bytes, it's easier to read =o)

This post was last modified: 01-08-2011 02:58 AM by mikshaw.

01-08-2011 02:55 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
converting seconds to %H:%M:%S - mikshaw - 01-08-2011 02:55 AM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: