Environment versions
Network:
Windows 2000 Server
After some experimenting it seems SECONDS() is also not completely reliable, somehow it gets out of sync with the datetime() value...
So we better use the winapi to get the systemtime (see below)
>function DateTimeExt
>* extend datetime() with millisecond reso
>LOCAL ltNow,lnSeconds
>ltNow=DATETIME()
>lnSeconds=SECONDS()
>* check if we didnt get an timeupdate during the 'store'
>DO WHILE SEC(ltNow)<>INT(MOD(lnSeconds,60))
> ltNow=DATETIME()
> lnSeconds=SECONDS()
>ENDDO
>RETURN DTOT(TTOD(ltNow))+lnSeconds
New version:
function DateTimeExt
DECLARE GetLocalTime IN kernel32 STRING @ lpSystemTime
LOCAL lcTimeBuffer,ltNow
lcTimeBuffer = REPLI (Chr(0), 16) && SYSTEMTIME structure
= GetLocalTime (@lcTimeBuffer)
ltNow=DATETIME(buf2word (SUBSTR(lcTimeBuffer, 1, 2)),;
buf2word (SUBSTR(lcTimeBuffer, 3, 2)),;
buf2word (SUBSTR(lcTimeBuffer, 7, 2)),;
buf2word (SUBSTR(lcTimeBuffer, 9, 2)),;
buf2word (SUBSTR(lcTimeBuffer, 11, 2)),;
buf2word (SUBSTR(lcTimeBuffer, 13, 2))) ;
+ buf2word (SUBSTR(lcTimeBuffer, 15, 2))/1000
RETURN ltNow
FUNCTION buf2word (lcBuffer)
RETURN;
Asc(SUBSTR(lcBuffer, 1,1)) + ;
Asc(SUBSTR(lcBuffer, 2,1)) * 256
ENDFUNC
* if you have VFP9 you can replace the buf2word call with ctobin(substr(..),'2RS')
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only