[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Win32 support for TimeZone info



I know a while back Alec sent out a summary of this to the group,
but I thought some might be interested in the more detailed
information below:

Win32 contains a function call GetTimeZoneInformation which fills in
a passed in TIME_ZONE_INFORMATION structure.  Information about
this structure may be found below.  (I found the Day-in-month format
interesting)

There is also a SetTimeZoneInformation call which lets you set items
in this structure.  It's not clear to me if using this call only impacts your
Win32 application's future usage of the GetTimeZoneInformation call
or all other Win32 applications running on your machine's future usage
of this call.

For my machine, I found that the StandardDate and DaylightDates are
actually specified in Day-in-month format (the year is 0, and it specifies
on which day of week in a particular month the transition occurs).  The
StandardName and DaylightName fields are actually full UNICODE
representations of "Eastern Daylight Time" and "Eastern Standard Time".

Win32's specifying this as a RULE instead of absolute trasition dates
for applicable timezones seems like a worthwhile thing to support
within the COS.  It doesn't appear either the Microsoft of the Versit
proposals presently support this.  The ability to specify this using
the recurrence grammar may be worthwhile.

Lastly, it is important for an application to be able to somehow obtain
the correct TimeZoneId.  I was hoping the DaylightName and
StandardName fields below may provide a way of doing this for
Win32, but these are presently full names and not "EDT" and "EST",
and I'm not convinced that parsing this and taking the first
character of each word will work for other time zones.  Anyone have
any suggestions on how to best do this on Win32?

Applications implementing such protocols will need to either garner
this info from the operating system, or somehow require users specify
this info as part of application setup.

- Vinod


The TIME_ZONE_INFORMATION structure specifies information specific to the time 
zone. 
  
typedef struct _TIME_ZONE_INFORMATION { // tzi 
    LONG       Bias; 
    WCHAR      StandardName[ 32 ]; 
    SYSTEMTIME StandardDate; 
    LONG       StandardBias; 
    WCHAR      DaylightName[ 32 ]; 
    SYSTEMTIME DaylightDate; 
    LONG       DaylightBias; 
} TIME_ZONE_INFORMATION; 
 
  
Members
Bias
Specifies the current bias, in minutes, for local time translation on this 
computer. The bias is the difference, in minutes, between Coordinated Universal 
Time (UTC) and local time. All translations between UTC and local time are 
based on the following formula: 
  
 
UTC = local time + bias 
 
  
This member is required. 
StandardName
Specifies a null-terminated string associated with standard time on this 
operating system. For example, this parameter could contain "EST" to indicate 
Eastern Standard Time. This string is not used by the operating system, so 
anything stored there by using the SetTimeZoneInformation function is returned 
unchanged by the GetTimeZoneInformation function. This string can be empty. 
StandardDate
Specifies a SYSTEMTIME structure that contains a date and UTC when the 
transition from daylight time to standard time occurs on this operating system. 
If this date is not specified, the wMonth member in the SYSTEMTIME structure 
must be zero. If this date is specified, the DaylightDate value in the 
TIME_ZONE_INFORMATION structure must also be specified. Local time translations 
done during the standard-time range are relative to the supplied StandardBias 
value. 
This member supports two date formats. Absolute format specifies an exact date 
and time when standard time begins. In this form, the wYear, wMonth, wDay, wHour
, wMinute, wSecond, and wMilliseconds members of the SYSTEMTIME structure are 
used to specify an exact date. 
Day-in-month format is specified by setting the wYear member to zero, setting 
the wDayOfWeek member to an appropriate weekday, and using a wDay value in the 
range 1 through 5 to select the correct day in the month. Using this notation, 
the first Sunday in April can be specified, as can the last Thursday in October 
(5 is equal to "the last"). 
StandardBias
Specifies a bias value to be used during local time translations that occur 
during standard time. This member is ignored if a value for the StandardDate 
member is not supplied. 
This value is added to the value of the Bias member to form the bias used 
during standard time. In most time zones, the value of this member is zero. 
DaylightName
Specifies a null-terminated string associated with daylight time on this 
operating system. For example, this parameter could contain "PDT" to indicate 
Pacific Daylight Time. This string is not used by the operating system, so 
anything stored there by using the SetTimeZoneInformation function is returned 
unchanged by the GetTimeZoneInformation function. This string can be empty. 
DaylightDate
Specifies a SYSTEMTIME structure that contains a date and UTC when the 
transition from standard time to daylight time occurs on this operating system. 
If this date is not specified, the wMonth member in the SYSTEMTIME structure 
must be zero. If this date is specified, the StandardDate value in the 
TIME_ZONE_INFORMATION structure must also be specified. Local time translations 
during the daylight-time range are relative to the supplied DaylightBias value. 
This member supports the absolute and day-in-month time formats described for 
the StandardDate member. 
DaylightBias
Specifies a bias value to be used during local time translations that occur 
during daylight time. This member is ignored if a value for the DaylightDate 
member is not supplied. 
This value is added to the value of the Bias member to form the bias used 
during daylight time. In most time zones, the value of this member is  - 60.