Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Nov 19, 2002 12:40 pm Post subject: Time zone |
|
|
Obtain time zone info from the Registry and obtain the computer's offset from GMT time etc.
Greetz
Dr. Dread
Code: |
option decimalsep,"."
rem Get values from Registry
%%zonename = @regread(LOCAL,SYSTEM\CurrentControlSet\Control\TimeZoneInformation,Standardname)
%%info = Time zone:@Tab()%%zonename
%%bias = @regread(LOCAL,SYSTEM\CurrentControlSet\Control\TimeZoneInformation,ActiveTimeBias)
rem WinNT/XP/2000 will return an integer, e.g. -120
rem Win9x will return a value like this 136|255|255|255 - convert it to an integer
if @greater(@pos(|,%%bias),0)
parse "%1;%2;%3;%4",%%bias
%%bias = @sum(@sum(@sum(%1,@prod(256,%2)),@prod(65536,%3)),@prod(16777216,%4))
end
rem Get the system's own time
%%local = @datetime()
%%info = %%info@CR()Local time:@Tab()@datetime(tt "("dddddd")")
rem Compute GMT time from that value - to get true GMT time use a time server
rem First find out the value of 1 minute
%%minute = @format(@fdiv(1,1440),.12)
rem Then extrapolate GMT time (local time + the value of the timezone bias)
%%GMT = @fadd(@format(%%local,.12),@fmul(%%bias,%%minute))
%%info = %%info@CR()GMT time:@TAB()@datetime(tt "("dddddd")",%%GMT)
rem Show offset
%%offset = @div(%%bias,-60)
if @equal(%%offset,1)@equal(%%offset,-1)
%%offset = %%offset hour
else
%%offset = %%offset hours
end
%%info = %%info@CR()Offset:@Tab()@Tab()%%offset
info %%info
|
_________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|