Re: [pgsql-hackers-win32] Weird new time zone
От | Dann Corbit |
---|---|
Тема | Re: [pgsql-hackers-win32] Weird new time zone |
Дата | |
Msg-id | 54798A299E68514AB7C4DEBA25F03BE101BB88@postal.corporate.connx.com обсуждение исходный текст |
Список | pgsql-hackers |
> -----Original Message----- > From: Tom Lane [mailto:tgl@sss.pgh.pa.us] > Sent: Thursday, July 15, 2004 10:03 PM > To: Dann Corbit > Cc: Oliver Jowett; Magnus Hagander; Hackers; > pgsql-hackers-win32@postgresql.org > Subject: Re: [pgsql-hackers-win32] [HACKERS] Weird new time zone > > > "Dann Corbit" <DCorbit@connx.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.
В списке pgsql-hackers по дате отправления: