At 04:38 7/24/2003, Rob Arends wrote:
>But how do you determine WHEN to apply the daylight offset and WHAT is the
>offset?

// TSInfo.cpp : Defines the entry point for the console application.
//

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

// there's probably a better way to handle this part
// but I was in a hurry and didn't look for it...:)
LPTSTR ordinals[] = {"",
                  "first",
                  "second",
                  "third",
                  "fourth",
                  "fifth"};

LPTSTR weekdays[] = {"Sunday",
                  "Monday",
                  "Tuesday",
                  "Wednesday",
                  "Thursday",
                  "Friday",
                  "Saturday"};

LPTSTR months[] = {  "January",
                  "February",
                  "March",
                  "April",
                  "May",
                  "June",
                  "July",
                  "August",
                  "September",
                  "October",
                  "November",
                  "December"};

int main(int argc, char* argv[])
{
         TIME_ZONE_INFORMATION tz;
         DWORD status;

         status = GetTimeZoneInformation(&tz);
         switch (status)
         {
         case TIME_ZONE_ID_INVALID:
                 {
                         DWORD count;
                         LPTSTR buffer;

                         count = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
                                           FORMAT_MESSAGE_ALLOCATE_BUFFER |
                                           FORMAT_MESSAGE_IGNORE_INSERTS,
                                           0,
                                           GetLastError(),
                                           0,
                                           buffer,
                                           0,
                                           0);
                         printf("%s\r\n", buffer);
                         LocalFree((HLOCAL)buffer);
                         break;
                 }
         case TIME_ZONE_ID_UNKNOWN:
                 {
                         printf("Unknown time zone information\r\n");
                         break;
                 }
         default:
                 {
                         if (status == TIME_ZONE_ID_STANDARD)
                                 printf("Currently in Standard time\r\n");
                         else if (status == TIME_ZONE_ID_DAYLIGHT)
                                 printf("Currently in Daylight time\r\n");
                         else
                                 printf("Unable to determine Standard or 
Daylight");

                         printf("Your current offset from GMT is %i 
minutes\r\n",
                                         tz.Bias);

                         printf("Standard Time in your time zone is called 
%S\r\n",
                                         (LPWSTR)tz.StandardName);

                         if (tz.StandardDate.wYear == 0)
                                 printf("Standard Time starts on the %s %s 
in %s\r\n",
                                         ordinals[tz.StandardDate.wDay],
                                         weekdays[tz.StandardDate.wDayOfWeek],
                                         months[tz.StandardDate.wMonth]);
                         else
                                 printf("Standard Time starts on %s, %n %s 
%n\r\n",
                                         weekdays[tz.StandardDate.wDayOfWeek],
                                         tz.StandardDate.wDay,
                                         months[tz.StandardDate.wMonth],
                                         tz.StandardDate.wYear);

                         printf("Standard Time bias is %i minutes\r\n",
                                         tz.StandardBias);

                         printf("Daylight Time in your time zone is called 
%S\r\n",
                                         (LPWSTR)tz.DaylightName);

                         if (tz.DaylightDate.wYear == 0)
                                 printf("Daylight Time starts on the %s %s 
in %s\r\n",
                                         ordinals[tz.DaylightDate.wDay],
                                         weekdays[tz.DaylightDate.wDayOfWeek],
                                         months[tz.DaylightDate.wMonth]);
                         else
                                 printf("Standard Time starts on %s, %n %s 
%n\r\n",
                                         weekdays[tz.DaylightDate.wDayOfWeek],
                                         tz.DaylightDate.wDay,
                                         months[tz.DaylightDate.wMonth],
                                         tz.DaylightDate.wYear);

                         printf("Daylight Time bias is %i minutes\r\n",
                                         tz.DaylightBias);
                 }

         }
         return 0;
}


-
To unsubscribe from this list: send the line "unsubscribe xmail" in
the body of a message to [EMAIL PROTECTED]
For general help: send the line "help" in the body of a message to
[EMAIL PROTECTED]

Reply via email to