Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Universal Time Local Time
It does NOT check that the input is actually a valid time. (If the time is invalid, the returned value will be nonsense.)
Note: On Windows NT there is a single API SystemTimeToTzSpecificLocalTime that could do this conversion, but I didn't use it because it is not available in Windows 9x.
; Input is a time in YmdHms format. ; Output is also YmdHms, but converted ; to local time. #DefineFunction UniversalToLocal(Time) ST = BinaryAlloc(16) FT1 = BinaryAlloc(8) FT2 = BinaryAlloc(8) Yr = Int(ItemExtract(1,Time,":")) ; Must have 4 digit years. if Yr < 100 then Yr = 2000 + Yr ; Assume 2 digit years are 20xx. BinaryPoke2(ST, 0,Yr) ; Fill a SYSTEMTIME structure BinaryPoke2(ST, 2,Int(ItemExtract(2,Time,":"))) BinaryPoke2(ST, 6,Int(ItemExtract(3,Time,":"))) BinaryPoke2(ST, 8,Int(ItemExtract(4,Time,":"))) BinaryPoke2(ST,10,Int(ItemExtract(5,Time,":"))) BinaryPoke2(ST,12,Int(ItemExtract(6,Time,":"))) ; Do the time conversion kernel32 = DllLoad(strcat(dirwindows(1),"Kernel32.DLL")) DllCall(kernel32,lpstr:"SystemTimeToFileTime",lpbinary:ST, lpbinary:FT1) DllCall(kernel32,lpstr:"FileTimeToLocalFileTime",lpbinary:FT1, lpbinary:FT2) DllCall(kernel32,lpstr:"FileTimeToSystemTime",lpbinary:FT2, lpbinary:ST) DllFree(Kernel32) Local = Strcat(BinaryPeek2(ST,0),":",BinaryPeek2(ST,2),":",BinaryPeek2(ST,6),":",BinaryPeek2(ST,8),":",BinaryPeek2(ST,10),":",BinaryPeek2(ST,12)) BinaryFree(ST) BinaryFree(FT1) BinaryFree(FT2) return Local #EndFunction
Article ID: W14963File Created: 2001:11:08:12:41:10Last Updated: 2001:11:08:12:41:10