Code: Select all
;unreliable:
vDate := A_Now A_MSec
;unreliable:
vDate := A_YYYY "-" A_MM "-" A_DD
vTime := A_Hour "-" A_Min "-" A_Sec
vDate := A_YYYY "-" A_MM "-" A_DD " " A_Hour "-" A_Min "-" A_Sec
;reliable:
FormatTime, vDate,, yyyy-MM-dd
FormatTime, vTime,, HH-mm-ss
FormatTime, vDate,, yyyy-MM-dd HH-mm-ss
;reliable:
MsgBox, % vDate := RegExReplace(A_Now, "(....)(..)(..)......", "$1-$2-$3")
MsgBox, % vDate := RegExReplace(A_Now, "........(..)(..)(..)", "$1-$2-$3")
MsgBox, % vDate := RegExReplace(A_Now, "(....)(..)(..)(..)(..)(..)", "$1-$2-$3 $4-$5-$6")
;reliable:
MsgBox, % vDate := RegExReplace(A_Now, "(....)(..)(..).{6}", "$1-$2-$3")
MsgBox, % vDate := RegExReplace(A_Now, ".{8}(..)(..)(..)", "$1-$2-$3")
MsgBox, % vDate := RegExReplace(A_Now, "(....)(..)(..)(..)(..)(..)", "$1-$2-$3 $4-$5-$6")
[I provide a DllCall method there to achieve 'A_Now A_MSec' reliably]
jeeswg's documentation extension tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=33596
I am trying to create a native AutoHotkey solution, I believe this code is correct. I share in case anyone has any other ideas, or notices a problem below. Even simple while loops can be a little tricky. Thanks for reading.
Code: Select all
q:: how many datestamps can be retrieved per second
vOutput := ""
VarSetCapacity(vOutput, 1000000*2)
vTickCount1 := A_TickCount
Loop, 100000
vOutput .= A_MSec "`r`n"
vTickCount2 := A_TickCount
Clipboard := (vTickCount2 - vTickCount1) "`r`n`r`n" vOutput
MsgBox, % "done"
return
w:: ;attempt at a native 'A_Now A_MSec' solution
vDate2 := A_Now A_MSec
Loop
{
vDate := A_Now A_MSec
if (vDate = vDate2)
break
vDate2 := vDate
}
MsgBox, % vDate
return
e:: ;attempt at a shorter 'A_Now A_MSec' solution
vDate2 := A_Now A_MSec
while !((vDate := A_Now A_MSec) = vDate2)
vDate2 := vDate
MsgBox, % vDate
return
Variables and Expressions
https://autohotkey.com/docs/Variables.htm#BuiltIn
FormatTime
https://autohotkey.com/docs/commands/FormatTime.htm