List Info

Thread: GetTimeZoneInformation question




GetTimeZoneInformation question
user name
2007-10-14 17:27:52
Hi all,

The following code snippet isn't working terribly well for
me. I can get 
the Bias, StandardName and DaylightName, but everything else
is goofed 
up. The alignment seems ok, but maybe I've missed something
or maybe I 
have to do extra work to unpack the SYSTEMTIME structures.

require 'windows/time'
include Windows::Time

buf = 0.chr * 172 # sizeof(TIME_ZONE_INFORMATION)
GetTimeZoneInformation(buf)

p buf[0,4].unpack('L')[0]    # Bias
p buf[4,64].tr("",'')      # StandardName
p buf[68,2].unpack('S')[0]   # Year
p buf[70,2].unpack('S')[0]   # Month
p buf[72,2].unpack('S')[0]   # DOW
p buf[74,2].unpack('S')[0]   # Day
p buf[76,2].unpack('S')[0]   # Hour
p buf[78,2].unpack('S')[0]   # Minute
p buf[80,2].unpack('S')[0]   # Second
p buf[82,2].unpack('S')[0]   # Millisecond
p buf[84,4].unpack('S')[0]   # StandardBias
p buf[88,64].tr("",'')     # DaylightName
p buf[152,2].unpack('S')[0]  # Year
p buf[154,2].unpack('S')[0]  # Month
p buf[156,2].unpack('S')[0]  # DOW
p buf[158,2].unpack('S')[0]  # Day
p buf[160,2].unpack('S')[0]  # Hour
p buf[162,2].unpack('S')[0]  # Minute
p buf[164,2].unpack('S')[0]  # Second
p buf[166,2].unpack('S')[0]  # Millisecond
p buf[168,4].unpack('L')[0]  # DaylightBias

Regards,

Dan
_______________________________________________
win32utils-devel mailing list
win32utils-develrubyforge.org
http://rubyforge.org/mailman/listinfo/win32utils-devel


Re: GetTimeZoneInformation question
user name
2007-10-14 20:01:34

Hi,
 ;
2007/10/15, Daniel Berger < djberg96gmail.com">djberg96gmail.com>:
Hi all,

The following code snippet isn't working terribly well for me. I can get
the Bias, StandardName and DaylightName, but everything else is goofed
up. The alignment seems ok, but maybe I've missed something or maybe I
have to do extra work to unpack the SYSTEMTIME structures.

require 'windows/time';
include Windows::Time

buf = 0.chr * 172 # sizeof(TIME_ZONE_INFORMATION)
GetTimeZoneInformation(buf)

p buf[0,4].unpack('L')[0]&nbsp;   ;# Bias
p buf[4,64].tr("&quot;,'') ; &nbsp; &nbsp; # StandardName
p buf[68,2].unpack(';S')[0]  ; # Year
p buf[70,2].unpack(';S')[0]  ; # Month
p buf[72,2].unpack(';S')[0]  ; # DOW
p buf[74,2].unpack(';S')[0]  ; # Day
p buf[76,2].unpack(';S')[0]  ; # Hour
p buf[78,2].unpack(';S')[0]  ; # Minute
p buf[80,2].unpack(';S')[0]  ; # Second
p buf[82,2].unpack(';S')[0]  ; # Millisecond
p buf[84,4].unpack(';S')[0]  ; # StandardBias
p buf[88,64].tr("",';')&nbsp; &nbsp;  # DaylightName
p buf[152,2].unpack(9;S')[0] &nbsp;# Year
p buf[154,2].unpack(9;S')[0] &nbsp;# Month
p buf[156,2].unpack(9;S')[0] &nbsp;# DOW
p buf[158,2].unpack(9;S')[0] &nbsp;# Day
p buf[160,2].unpack(9;S')[0] &nbsp;# Hour
p buf[162,2].unpack(9;S')[0] &nbsp;# Minute
p buf[164,2].unpack(9;S')[0] &nbsp;# Second
p buf[166,2].unpack(9;S')[0] &nbsp;# Millisecond
p buf[168,4].unpack(9;L')[0] &nbsp;# DaylightBias

Regards,

Dan
 
The SYSTEMTIME structure field StandarddDate and DaylightDate is not used with GetTimeZoneInformation API, but used with SetTimeZoneInformation.
 ;
 
Regards,
 
Park Heesob

&nbsp;

Re: GetTimeZoneInformation question
user name
2007-10-14 20:23:44
Heesob Park wrote:
> 
> Hi,
>  
> 2007/10/15, Daniel Berger <djberg96gmail.com
<mailto:djberg96gmail.com>>:
> 
>     Hi all,
> 
>     The following code snippet isn't working terribly
well for me. I can get
>     the Bias, StandardName and DaylightName, but
everything else is goofed
>     up. The alignment seems ok, but maybe I've missed
something or maybe I
>     have to do extra work to unpack the SYSTEMTIME
structures.
> 
>     require 'windows/time'
>     include Windows::Time
> 
>     buf = 0.chr * 172 # sizeof(TIME_ZONE_INFORMATION)
>     GetTimeZoneInformation(buf)
> 
>     p buf[0,4].unpack('L')[0]    # Bias
>     p buf[4,64].tr("",'')      #
StandardName
>     p buf[68,2].unpack('S')[0]   # Year
>     p buf[70,2].unpack('S')[0]   # Month
>     p buf[72,2].unpack('S')[0]   # DOW
>     p buf[74,2].unpack('S')[0]   # Day
>     p buf[76,2].unpack('S')[0]   # Hour
>     p buf[78,2].unpack('S')[0]   # Minute
>     p buf[80,2].unpack('S')[0]   # Second
>     p buf[82,2].unpack('S')[0]   # Millisecond
>     p buf[84,4].unpack('S')[0]   # StandardBias
>     p buf[88,64].tr("",'')     #
DaylightName
>     p buf[152,2].unpack('S')[0]  # Year
>     p buf[154,2].unpack('S')[0]  # Month
>     p buf[156,2].unpack('S')[0]  # DOW
>     p buf[158,2].unpack('S')[0]  # Day
>     p buf[160,2].unpack('S')[0]  # Hour
>     p buf[162,2].unpack('S')[0]  # Minute
>     p buf[164,2].unpack('S')[0]  # Second
>     p buf[166,2].unpack('S')[0]  # Millisecond
>     p buf[168,4].unpack('L')[0]  # DaylightBias
> 
>     Regards,
> 
>     Dan
> 
>  
> The SYSTEMTIME structure field StandarddDate and
DaylightDate is not 
> used with GetTimeZoneInformation API, but used with
SetTimeZoneInformation.
>  
> Refer to the sample vbnet code at 
> http://vbnet.mvps.org/index.html?code/locale/get
timezoneinfo.htm
>  
> Regards,
>  
> Park Heesob

Oh, silly me. Disregard.

Dan
_______________________________________________
win32utils-devel mailing list
win32utils-develrubyforge.org
http://rubyforge.org/mailman/listinfo/win32utils-devel


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )