Hello,

I'm afraid Windows does not use "America/New_York" notation (internally, I
mean). Here is MSDN article (emphasis is mine):

TIME_ZONE_INFORMATION
The TIME_ZONE_INFORMATION structure specifies information specific to the
time zone. 

typedef struct _TIME_ZONE_INFORMATION { 
    LONG       Bias; 
    WCHAR      StandardName[ 32 ]; 
    SYSTEMTIME StandardDate; 
    LONG       StandardBias; 
    WCHAR      DaylightName[ 32 ]; 
    SYSTEMTIME DaylightDate; 
    LONG       DaylightBias; 
} TIME_ZONE_INFORMATION, *PTIME_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 member could contain "EST" to indicate
Eastern Standard Time. HERE -> **This string is not used by the operating
system, so anything stored there using the SetTimeZoneInformation function
is returned unchanged by the GetTimeZoneInformation function. This string
can be empty.** <- HERE

StandardDate 
Specifies a SYSTEMTIME structure that contains a date and local time when
the transition from daylight saving 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. 
To select the correct day in the month, set the wYear member to zero, the
wDayOfWeek member to an appropriate weekday, and the wDay member to a value
in the range 1 through 5. 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 saving time on
this operating system. For example, this member could contain "PDT" to
indicate Pacific Daylight Time. HERE -> **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. ** <- HERE

DaylightDate 
Specifies a SYSTEMTIME structure that contains a date and local time when
the transition from standard time to daylight saving 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. 
To select the correct day in the month, set the wYear member to zero, the
wDayOfWeek member to an appropriate weekday, and the wDay member to a value
in the range 1 through 5. Using this notation, the first Sunday in April can
be specified, as can the last Thursday in October (5 is equal to "the
last"). 

DaylightBias 
Specifies a bias value to be used during local time translations that occur
during daylight saving 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 saving time. In most time zones, the value of this member is
- 60. 

I've written little test, here are its source and output:

----

#include <windows.h>
#include <stdio.h>

void PrintTime(SYSTEMTIME *st)
{
        printf("%04d %02d %02d %02d:%02d:%02d (%d dow, %d milliseconds)\n",
                st->wYear, st->wMonth, st->wDay,
                st->wHour, st->wMinute, st->wSecond,
                st->wDayOfWeek, st->wMilliseconds);
}

int main(int argc, char **argv)
{
        TIME_ZONE_INFORMATION sTZ;
        DWORD dwRet = GetTimeZoneInformation(&sTZ);

        switch (dwRet)
        {
                case TIME_ZONE_ID_UNKNOWN:
                        printf("TIME_ZONE_ID_UNKNOWN:\n");
                        break;

                case TIME_ZONE_ID_STANDARD:
                        printf("TIME_ZONE_ID_STANDARD:\n");
                        break;

                case TIME_ZONE_ID_DAYLIGHT:
                        printf("TIME_ZONE_ID_DAYLIGHT:\n");
                        break;

                case TIME_ZONE_ID_INVALID:
                        {
                                LPVOID lpMsgBuf;
                        FormatMessage( 
                  FORMAT_MESSAGE_ALLOCATE_BUFFER | 
                                    FORMAT_MESSAGE_FROM_SYSTEM | 
                            FORMAT_MESSAGE_IGNORE_INSERTS,
                  NULL,
                                    GetLastError(),
                            MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //
Default language
                  (LPTSTR) &lpMsgBuf,
                                    0,
                            NULL 
              );
                                printf("Cannot obtain timezone information
(%s)\n",
                                        (const char *) lpMsgBuf);
                        }
                        return -1;

                default:
                        printf("Cannot obtain timezone information: unknown
return value (%d)\n",
                                dwRet);
                        return -1;
        }

        const int ciDim = 40;
        char buff[ciDim];
        
        printf("Bias: %d\n", sTZ.Bias);

        size_t size = wcstombs(0, sTZ.StandardName, -1);
        if (size == (size_t) -1 || size >= ciDim)
        {
                printf("Not enough space to convert name (%d needed)\n",
size);
        }
        else
        {
                wcstombs(buff, sTZ.StandardName, -1);
                printf("StandardName: %s\n", buff);
        }

        printf("StandardDate: ");
        PrintTime(&sTZ.StandardDate);

        printf("StandardBias: %d\n", sTZ.StandardBias);

        size = wcstombs(0, sTZ.DaylightName, -1);
        if (size == (size_t) -1 || size >= ciDim)
        {
                printf("Not enough space to convert name (%d needed)\n",
size);
        }
        else
        {
                wcstombs(buff, sTZ.DaylightName, -1);
                printf("DaylightName : %s\n", buff);
        }

        printf("DaylightDate: ");
        PrintTime(&sTZ.DaylightDate);

        printf("DaylightBias: %d\n", sTZ.DaylightBias);


        return 0;
}

-----

TIME_ZONE_ID_STANDARD:
Bias: -360
StandardName: N. Central Asia Standard Time
StandardDate: 0000 10 05 03:00:00 (0 dow, 0 milliseconds)
StandardBias: 0
DaylightName : N. Central Asia Standard Time
DaylightDate: 0000 03 05 02:00:00 (0 dow, 0 milliseconds)
DaylightBias: -60

                       Best regards, Elliot.
 
----------------------------------------------------------------------------
-------------------
Ilya A. Tereshchenko
Developer
Aurorisoft Inc.
 
E-mail: [EMAIL PROTECTED]
For more visit http://www.aurorisoft.com/
----------------------------------------------------------------------------
------------------- 

> -----Original Message-----
> From: Dave Rolsky [mailto:[EMAIL PROTECTED]
> Sent: Friday, February 06, 2004 6:42 AM
> To: Jamie LeTual
> Cc: datetime
> Subject: Re: local timezone
> 

[skip]

> The problem is that DateTime wants something like "America/New_York", not
> "Atlantic Standard Time", whichi isn't really the right timezone, most
> likely.  AST, which is probably the same as EST, is only valid for half of
> the year on most of the US Atlantic coast.
> 
> So we don't want to know what the current offset is, instead we want to
> know the geo-political time zone name.

Reply via email to