NO

Author Topic: _ftime problem  (Read 29203 times)

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
_ftime problem
« Reply #30 on: January 14, 2005, 02:42:16 PM »
Hello Garvan,

Quote from: "Garvan"
Sorry for not making my report clearer. localtime is also wrong.

No problems.

I use the Windows API function GetTimeZoneInformation() to get the time zone bias - it's the best I can find, but I'm no expert in this area.

If I set it to "(GMT+07:00) Bangkok, Hanoi, ..." on my Windows XP, I get TIME_ZONE_ID_UNKNOWN, but if I set it to "(GMT+07:00) Krasnoyarsk" I get TIM_ZONE_ID_STANDARD, Bias = -420.

I have attached the a simple test program for GetTimeZoneInformation() - what does it return on your computer?

Pelle
/Pelle

Garvan

  • Guest
_ftime problem
« Reply #31 on: January 15, 2005, 08:30:57 AM »
Hi:

This is what I get! Same result with VC++

GetTimeZoneInformation() returned TIME_ZONE_ID_UNKNOWN
(Windows cannot determine the current time zone...)


Garvan

Greg

  • Guest
_ftime problem
« Reply #32 on: January 15, 2005, 08:43:56 PM »
Garvan & Pelle,

That's what it should return under Windows NT/2000/XP. (GMT+07:00) Bangkok, Hanoi, Jakarta does not use Daylight Saving Time. So GetTimeZoneInformation() will return TIME_ZONE_ID_UNKNOWN, which is misleading.

See MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/gettimezoneinformation.asp

It boils down to:
TIME_ZONE_ID_DAYLIGHT = Daylight Time
TIME_ZONE_ID_STANDARD or TIME_ZONE_ID_UNKNOWN = Standard Time
TIME_ZONE_ID_INVALID =  GetTimeZoneInformation() failed

Offline Robert

  • Member
  • *
  • Posts: 247
GetLocalTime Not the Same if Adjusting for Daylight
« Reply #33 on: January 16, 2005, 01:04:44 AM »
For a related problem please see

SetLocalTime/GetLocalTime Not the Same if Adjusting for Daylight Savings Time

http://support.microsoft.com/kb/q234735/

Robert Wishlaw

Greg

  • Guest
_ftime problem
« Reply #34 on: January 16, 2005, 01:40:43 AM »
Re: GetTimeZoneInformation

The meanings of the returned value changed with Windows NT. Some older code examples use the Windows 9x meanings.

Greg

  • Guest
_ftime problem
« Reply #35 on: January 16, 2005, 03:31:27 AM »
An example of what I'm trying to say:
Code: [Select]

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

int main(void)
{
    TIME_ZONE_INFORMATION tzi;

    switch (GetTimeZoneInformation(&tzi))
    {
    case TIME_ZONE_ID_DAYLIGHT:
    /* Windows 9x/ME/NT/2000/XP - The current time zone is on Daylight Saving Time */
            printf("GetTimeZoneInformation() returned TIME_ZONE_ID_DAYLIGHT:\n");
            printf("Bias: %ld\n", tzi.Bias);
            printf("DaylightName: %ls\n", tzi.DaylightName); /* This is a Unicode string */
            printf("DaylightBias: %ld\n", tzi.DaylightBias);
            break;
           
        case TIME_ZONE_ID_STANDARD:
        /* Windows NT/2000/XP - the current time zone is on Standard Time */
        /* Windows 9x/ME - The current time zone does not use Daylight Saving Time or
          the current time zone is on Standard Time */
            printf("GetTimeZoneInformation() returned TIME_ZONE_ID_STANDARD:\n");
            printf("Bias: %ld\n", tzi.Bias);
            printf("StandardName: %ls\n", tzi.StandardName); /* This is a Unicode string */
            printf("StandardBias: %ld\n", tzi.StandardBias);
            break;
           
case TIME_ZONE_ID_UNKNOWN:
/* Windows NT/2000/XP - The current time zone does not use Daylight Saving Time */
        printf("GetTimeZoneInformation() returned TIME_ZONE_ID_UNKNOWN:\n");
            printf("Bias: %ld\n", tzi.Bias);
            printf("StandardName: %ls\n", tzi.StandardName); /* This is a Unicode string */
            printf("StandardBias: %ld\n", tzi.StandardBias);
            break;
       
    case TIME_ZONE_ID_INVALID:
            printf("Error calling GetTimeZoneInformation()\n");
            break;
                           
default:
            printf("GetTimeZoneInformation() returned unknown value\n");
            break;            
    }

    return 0;
}

Garvan

  • Guest
_ftime problem
« Reply #36 on: January 17, 2005, 11:45:35 AM »
Hi:

Quote from: "Greg"

That's what it should return under Windows NT/2000/XP. (GMT+07:00) Bangkok, Hanoi, Jakarta does not use Daylight Saving Time. So GetTimeZoneInformation() will return TIME_ZONE_ID_UNKNOWN, which is misleading.


Thanks for this.

Garvan.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
_ftime problem
« Reply #37 on: January 24, 2005, 02:17:51 PM »
Thank you very much for the information, Greg!

Pelle
/Pelle