summaryrefslogtreecommitdiff
path: root/time
diff options
context:
space:
mode:
authorWilliam A. Rowe Jr <wrowe@apache.org>2003-01-22 19:39:43 +0000
committerWilliam A. Rowe Jr <wrowe@apache.org>2003-01-22 19:39:43 +0000
commit9f98ec363eeadad61d3bf9c08491db4554095628 (patch)
tree2e6288ab9bc7effb34ded1b97a2822e79c13bad5 /time
parentec814bbfb291519d1df35573cf5533db4ec71b2f (diff)
downloadapr-9f98ec363eeadad61d3bf9c08491db4554095628.tar.gz
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. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@64308 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'time')
-rw-r--r--time/win32/time.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/time/win32/time.c b/time/win32/time.c
index df5d5684d..3121c43aa 100644
--- a/time/win32/time.c
+++ b/time/win32/time.c
@@ -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 @@ APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result,
{
SYSTEMTIME st;
FILETIME ft, localft;
+ TIME_ZONE_INFORMATION *tz;
AprTimeToFileTime(&ft, input);
@@ -181,9 +183,8 @@ APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result,
{
SYSTEMTIME localst;
apr_time_t localtime;
- TIME_ZONE_INFORMATION *tz;
- tz = GetLocalTimeZone();
+ get_local_timezone(&tz);
FileTimeToSystemTime(&ft, &st);
@@ -218,8 +219,6 @@ APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result,
#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 @@ APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result,
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