wrowe 2003/01/22 11:39:43
Modified: time/win32 time.c
Log:
Finally, use the same cached recovery for the timezone between 9x and NT.
The 9x code is just wrong, so this change doesn't make worse.
Anyone with interest in helping tear away this problem, please speak up.
Revision Changes Path
1.44 +27 -28 apr/time/win32/time.c
Index: time.c
===================================================================
RCS file: /home/cvs/apr/time/win32/time.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- time.c 22 Jan 2003 19:17:55 -0000 1.43
+++ time.c 22 Jan 2003 19:39:43 -0000 1.44
@@ -72,19 +72,20 @@
*/
#define IsLeapYear(y) ((!(y % 4)) ? (((!(y % 400)) && (y % 100)) ? 1 : 0) :
0)
-#if APR_HAS_UNICODE_FS
-static LPTIME_ZONE_INFORMATION GetLocalTimeZone()
+static DWORD get_local_timezone(TIME_ZONE_INFORMATION **tzresult)
{
- static int init = 0;
static TIME_ZONE_INFORMATION tz;
+ static DWORD result;
+ static int init = 0;
if (!init) {
- GetTimeZoneInformation(&tz);
+ result = GetTimeZoneInformation(&tz);
init = 1;
}
- return &tz;
+
+ *tzresult = &tz;
+ return result;
}
-#endif
static void SystemTimeToAprExpTime(apr_time_exp_t *xt, SYSTEMTIME *tm)
{
@@ -173,6 +174,7 @@
{
SYSTEMTIME st;
FILETIME ft, localft;
+ TIME_ZONE_INFORMATION *tz;
AprTimeToFileTime(&ft, input);
@@ -181,9 +183,8 @@
{
SYSTEMTIME localst;
apr_time_t localtime;
- TIME_ZONE_INFORMATION *tz;
- tz = GetLocalTimeZone();
+ get_local_timezone(&tz);
FileTimeToSystemTime(&ft, &st);
@@ -218,8 +219,6 @@
#if APR_HAS_ANSI_FS
ELSE_WIN_OS_IS_ANSI
{
- TIME_ZONE_INFORMATION tz;
-
/* XXX: This code is simply *wrong*. The time converted will always
* map to the *now current* status of daylight savings time.
*/
@@ -229,25 +228,25 @@
SystemTimeToAprExpTime(result, &st);
result->tm_usec = (apr_int32_t) (input % APR_USEC_PER_SEC);
- switch (GetTimeZoneInformation(&tz)) {
- case TIME_ZONE_ID_UNKNOWN:
- result->tm_isdst = 0;
- /* Bias = UTC - local time in minutes
- * tm_gmtoff is seconds east of UTC
- */
- result->tm_gmtoff = tz.Bias * -60;
- break;
- case TIME_ZONE_ID_STANDARD:
- result->tm_isdst = 0;
- result->tm_gmtoff = (tz.Bias + tz.StandardBias) * -60;
- break;
- case TIME_ZONE_ID_DAYLIGHT:
- result->tm_isdst = 1;
- result->tm_gmtoff = (tz.Bias + tz.DaylightBias) * -60;
- break;
- default:
+ switch (get_local_timezone(&tz)) {
+ case TIME_ZONE_ID_UNKNOWN:
+ result->tm_isdst = 0;
+ /* Bias = UTC - local time in minutes
+ * tm_gmtoff is seconds east of UTC
+ */
+ result->tm_gmtoff = tz->Bias * -60;
+ break;
+ case TIME_ZONE_ID_STANDARD:
+ result->tm_isdst = 0;
+ result->tm_gmtoff = (tz->Bias + tz->StandardBias) * -60;
+ break;
+ case TIME_ZONE_ID_DAYLIGHT:
+ result->tm_isdst = 1;
+ result->tm_gmtoff = (tz->Bias + tz->DaylightBias) * -60;
+ break;
+ default:
/* noop */;
- }
+ }
}
#endif