From: | "Dann Corbit" <DCorbit(at)connx(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "Hackers" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [pgsql-hackers-win32] Weird new time zone |
Date: | 2004-07-16 06:38:55 |
Message-ID: | 54798A299E68514AB7C4DEBA25F03BE101BB88@postal.corporate.connx.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> -----Original Message-----
> From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
> Sent: Thursday, July 15, 2004 10:03 PM
> To: Dann Corbit
> Cc: Oliver Jowett; Magnus Hagander; Hackers;
> pgsql-hackers-win32(at)postgresql(dot)org
> Subject: Re: [pgsql-hackers-win32] [HACKERS] Weird new time zone
>
>
> "Dann Corbit" <DCorbit(at)connx(dot)com> writes:
> > All translations between UTC time and local time are based on the
> > following formula:
>
> > UTC = local time + bias
>
> Surely not. Or has Windows not heard of daylight-savings
> time? Or perhaps they have, but are not aware that the DST
> laws have changed often in the past?
No problems. They even handle time zones with arbitrary minute
boundaries (not on the hour) with aplomb.
> Over-simplistic answers are not what we need here. The data
> structure you quote cannot even tell what DST transition
> dates Windows thinks are in effect this year, let alone what
> it thinks the dates were in past years.
Yes, there are other calls for that, obviously. I sent to Mr. Momjian a
complete implementation of time zone stuff that uses Windows calls.
It's also accurate to a fraction of a nanosecond millions of years into
the past and the future.
The call that I showed returns the NAME OF THE TIME ZONE and also what
it is called when you are in Daylight savings time. I thought the issue
under question was to find out what the time zone was.
This program:
#include <windows.h>
#include <iostream>
using namespace std;
int main(void)
{
TIME_ZONE_INFORMATION tz;
DWORD i = GetTimeZoneInformation(&tz);
for (i = 0; i < 32 && tz.StandardName[i]; i++)
cout << (TCHAR) tz.StandardName[i];
cout << endl;
for (i = 0; i < 32 && tz.DaylightName[i]; i++)
cout << (TCHAR) tz.DaylightName[i];
cout << endl;
return 0;
}
Prints this:
Pacific Standard Time
Pacific Daylight Time
There is also a global variable called _tzname that contains the name of
the time zone.
See:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/h
tml/_crt__daylight.2c_._timezone.2c_.and__tzname.asp
On my machine:
cout << _tzname[0]; // -> PST
cout << _tzname[1]; // -> PDT
As far as doing the calculations for time values, do whatever you like
(it's not that difficult either, and the code I send does address all
that stuff, though it is in C++). Don't forget that things are inverted
in the southern hemisphere.
Have a good one.
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Glaesemann | 2004-07-16 06:59:01 | Re: Converting epoch to timestamp |
Previous Message | Peter Eisentraut | 2004-07-16 06:22:38 | Re: ODBC Developers |