AutoHotkey Community

It is currently May 27th, 2012, 12:13 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: January 5th, 2006, 5:16 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Although the actual computation is in one line, the function Chris added to the documentation takes another four to save, set and restore the format. This takes away the simplicity of the solution. Furthermore, the function does not use FormatTime, so the FormatTime page is an awkward place for it. The other functions are one line shorter and better demonstrate the use of FormatTime:
Code:
FormatSeconds(NumberOfSeconds) ; Convert up to 24 hours worth of seconds into hh:mm:ss format.
{
   Midnight = %A_YYYY%%A_MM%%A_DD%
   Midnight += %NumberOfSeconds%, seconds
   FormatTime, OutputVar, %Midnight%, HH:mm:ss  ; HH yields 24-hour format.
   return OutputVar
}

TimeLog(Seconds)
{
   time = 20000101
   time+= %Seconds%, seconds
   FormatTime mmss, %time%, mm:ss
   return Seconds//3600 ":" mmss
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2006, 1:57 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Okay, I changed it to be essentially the same as to the bottom function above. I'm sure the function's name still isn't optimal, and there may be other things not perfect about it:

Code:
; The following function converts the specified number of seconds into the
; corresponding number of hours, minutes, and seconds (hh:mm:ss format).

MsgBox % FormatSeconds(7384)  ; 7384 = 2 hours + 3 minutes + 4 seconds. It yields: 2:03:04

FormatSeconds(NumberOfSeconds)  ; Convert the specified number of seconds to hh:mm:ss format.
{
   time = 19990101  ; *Midnight* of an arbitrary date.
   time += %NumberOfSeconds%, seconds
   FormatTime, mmss, %time%, mm:ss
   return NumberOfSeconds//3600 ":" mmss  ; Allows support for more than 24 hours.
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, Yahoo [Bot] and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group