 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Bytales
Joined: 06 Sep 2008 Posts: 82
|
Posted: Mon Sep 08, 2008 12:39 am Post subject: Converting number in time format |
|
|
Is there a command to convert a number in time format ?
For instance, 56 would give 00h 00m 56s
And 65 would give 00h 01m 05s
You got the point ! |
|
| Back to top |
|
 |
Bytales
Joined: 06 Sep 2008 Posts: 82
|
Posted: Mon Sep 08, 2008 12:48 am Post subject: |
|
|
| Or do i have to write a script to do this ? |
|
| Back to top |
|
 |
Slanter
Joined: 28 May 2008 Posts: 397 Location: Minnesota, USA
|
Posted: Mon Sep 08, 2008 2:55 am Post subject: |
|
|
From the examples on the manual page for FormatTime
| 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 ; This method is used to support more than 24 hours worth of sections.
} |
_________________ Unless otherwise stated, all code is untested
(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination. |
|
| Back to top |
|
 |
Bytales
Joined: 06 Sep 2008 Posts: 82
|
Posted: Mon Sep 08, 2008 8:21 am Post subject: |
|
|
| Slanter wrote: | From the examples on the manual page for FormatTime
| 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 ; This method is used to support more than 24 hours worth of sections.
} |
|
Thanks, looks like i missed this, even though i'm browsing the help heavily since i found out about autohotkey 2 days ago !
Allthough i don't understand how this implementation works.
FormatSeconds(NumberOfSeconds), is that a function ?
And what exactly is 19990101 suppose to mean ?
I can't see how 7384 transforms in 2 3 4 !
What if i don't have a number?
Let's say i have the following variable
Time:=(A_Index-1)*10+1*2
Using FormatSeconds(Time) doesn't work in a tooltip |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6264
|
Posted: Mon Sep 08, 2008 9:40 am Post subject: |
|
|
Bytales,
| Quote: | | FormatSeconds(NumberOfSeconds), is that a function ? |
Yes!
| Quote: | | what exactly is 19990101 suppose to mean ? |
It is a valid time stamp 19990101000000 in short form ( Midnight of 1st Jan 1999 )
You could use your date-of-birth instead
I can't see how 7384 transforms in 2 3 4 !
| Code: | SecondsSinceBoot := A_TickCount/1000 ; Converting ms to secs
Somedate=16010101 ; The first computer calendar date
SomeDate += %SecondsSinceBoot%, Seconds
FormatTime,mm,%SomeDate%, mm ; Extract minutes from some date
FormatTime,ss,%SomeDate%, ss ; Extract seconds from some date
Hours := Round(SecondsSinceBoot//3600) ; Derive hours
MsgBox, 0, Computer Uptime, % "Hours`t: " Hours "`nMinutes`t: " mm "`nSeconds`t: " ss |
| Quote: | What if i don't have a number?
Let's say i have the following variable
Time:=(A_Index-1)*10+1*2 |
You may pass variable Time to the function. Are you applying the BODMAS rule there ?
| Quote: | | Using FormatSeconds(Time) doesn't work in a tooltip |
It should.
 _________________
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|