Skip to content
⌘ NSIS Forum Archive

UTC Time to Local Time ?

5 posts

sanghoang04#

UTC Time to Local Time ?

I need to get UTC time from internet - NIST, then convert to local time. I can get UTC time from nist, and know SystemTimeToTzSpecificLocalTime func can convert UTC to Local Time, but I don't know how to do it, because I don't know how to set SYSTEMTIME structure to UTC time I got from nist. I know NSIS remove SystemTimeToTzSpecificLocalTime because it made bugs in Win9x, but I still want use it. So anyone know how to do it please help me, and if posible tell the way to don't get bugs. Thank !!
Anders#
What is your UTC format? A 32bit UINT? time_t? Or do you have separate days/hour/minute values that you can fill in the SYSTEM_TIME struct with?

Originally Posted by sanghoang04 View Post
I know NSIS remove SystemTimeToTzSpecificLocalTime because it made bugs in Win9x, but I still want use it.
NSIS has never had a native function for this?
sanghoang04#
I get time from NIST Internet Time Service (ITS) "http://www.nist.gov/pml/div688/grp40/its.cfm" with ramdom time server - is "http://time.nist.gov:13" and get response in UTC time in day/time format:

56806 14-05-29 11:04:06 50 0 0 820.5 UTC(NIST) *


NIST just can get UTC time, not local time by bias, so I want to convert it to local time.

And NSIS don't have this type function, I want to say it have in Include Header, in Get File Time func in SysFun.nsh in older version of NSIS, but it made bug in Win9x so it has been removed.
Anders#
StrCpy $0 2014
StrCpy $1 6
StrCpy $2 7
StrCpy $3 12
StrCpy $4 34
StrCpy $5 56
StrCpy $6 666
System::Call '*$9(&i2r0,&i2r1,&i2,&i2r2,&i2r3,&i2r4,&i2r5,&i2r6)i.r9' ; Alloc and fill SYSTEMTIME
System::Alloc 16
Pop $1
System::Call 'KERNEL32::SystemTimeToTzSpecificLocalTime(i0,ir9,ir1)'
System::Call '*$1(&i2.r0,&i2.r1,&i2,&i2.r2,&i2.r3,&i2.r4,&i2.r5,&i2.r6)'
System::Free $9
System::Free $1
DetailPrint $0/$1/$2,$3:$4:$5.$6
You have to parse that server string yourself.