tc = now()
where
tc: number of milliseconds from 01jan1960 00:00:00.000, unadjusted for leap seconds [emphasis added]
where
tc: number of milliseconds from 01jan1960 00:00:00.000, unadjusted for leap seconds [emphasis added]
.ÿ
.ÿversionÿ17.0
.ÿ
.ÿclearÿ*
.ÿ
.ÿlocalÿline_sizeÿ`c(linesize)'
.ÿsetÿlinesizeÿ80
.ÿ
.ÿmata:
-------------------------------------------------ÿmataÿ(typeÿendÿtoÿexit)ÿ------
:ÿmataÿsetÿmatastrictÿon
:ÿ
:ÿvoidÿfunctionÿMS()ÿ{
>ÿ
>ÿÿÿÿÿÿÿÿÿrealÿscalarÿnow,ÿthen
>ÿ
>ÿÿÿÿÿÿÿÿÿthenÿ=ÿnow()
>ÿÿÿÿÿÿÿÿÿstata("sleepÿ250")
>ÿÿÿÿÿÿÿÿÿnowÿ=ÿnow()
>ÿ
>ÿÿÿÿÿÿÿÿÿassert(nowÿ==ÿthen)
>ÿ
>ÿÿÿÿÿÿÿÿÿrealÿscalarÿindex
>ÿÿÿÿÿÿÿÿÿforÿ(index=1;ÿindex<=2;ÿindex++)ÿ{
>ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿprintf("%tcHH:MM:SS.sss\n",ÿ(now,ÿthen)[index])
>ÿÿÿÿÿÿÿÿÿ}
>ÿ}
:ÿ
:ÿMS()
20:47:40.000
20:47:40.000
:ÿ
:ÿprintf("%3.0f\n",ÿclockpart(clock("00:00:00.125",ÿ"hms"),ÿ"ms"))
125
:ÿ
:ÿprintf("%3.0f\n",ÿclockpart(now(),ÿ"ms"))
ÿÿ0
:ÿ
:ÿend
--------------------------------------------------------------------------------
.ÿ
.ÿsetÿlinesizeÿ`line_size'
.ÿ
.ÿexit
endÿofÿdo-file
.
Is there any way to obtain full-precision clock time from the Mata function now(), or by any other way in Stata short of resorting to Python or Java?
Environment: Windows 10 Pro, 64-bit, current update
0 Response to Obtaining milliseconds from -now()-
Post a Comment