Use a -1 value for tm_isdst to guess time zone if it's unspecified.

This commit is contained in:
sperber 2001-07-11 13:08:52 +00:00
parent a4a437484d
commit 8726142251
1 changed files with 6 additions and 1 deletions

View File

@ -226,7 +226,6 @@ s48_value date2time(s48_value sec, s48_value min, s48_value hour,
d.tm_mon = s48_extract_fixnum (month); d.tm_mon = s48_extract_fixnum (month);
d.tm_year = s48_extract_fixnum (year); d.tm_year = s48_extract_fixnum (year);
d.tm_wday = 0; d.tm_yday = 0; d.tm_wday = 0; d.tm_yday = 0;
d.tm_isdst = (summer == S48_FALSE) ? 0 : 1;
if( S48_FIXNUM_P(tz_secs) ) { /* Offset from GMT in seconds. */ if( S48_FIXNUM_P(tz_secs) ) { /* Offset from GMT in seconds. */
char **oldenv = environ; /* Set TZ to UTC */ char **oldenv = environ; /* Set TZ to UTC */
@ -243,12 +242,17 @@ s48_value date2time(s48_value sec, s48_value min, s48_value hour,
environ = oldenv; environ = oldenv;
} }
/* ### Note that we *still* don't implement the manual paragraph
with "When calcultating with time-zones, the date's SUMMER?
field is used to resolve ambiguities. */
else if( S48_STRING_P(tz_name) ) { /* Time zone */ else if( S48_STRING_P(tz_name) ) { /* Time zone */
char *newenv[2]; char *newenv[2];
char **oldenv = make_newenv(tz_name, newenv); char **oldenv = make_newenv(tz_name, newenv);
if( !oldenv ) return s48_enter_fixnum(errno); if( !oldenv ) return s48_enter_fixnum(errno);
tzset(); /* NetBSD, SunOS POSIX-noncompliance requires this. */ tzset(); /* NetBSD, SunOS POSIX-noncompliance requires this. */
errno = 0; errno = 0;
d.tm_isdst = -1;
t = mktime(&d); t = mktime(&d);
if ((t == -1) && (errno != 0)) if ((t == -1) && (errno != 0))
s48_raise_os_error_5 (errno, sec, min, hour, mday, month); s48_raise_os_error_5 (errno, sec, min, hour, mday, month);
@ -258,6 +262,7 @@ s48_value date2time(s48_value sec, s48_value min, s48_value hour,
else { /* Local time */ else { /* Local time */
tzset(); /* NetBSD, SunOS POSIX-noncompliance requires this. */ tzset(); /* NetBSD, SunOS POSIX-noncompliance requires this. */
errno = 0; errno = 0;
d.tm_isdst = -1;
t = mktime(&d); t = mktime(&d);
if ((t == -1) && (errno != 0)) if ((t == -1) && (errno != 0))
s48_raise_os_error_5 (errno, sec, min, hour, mday, month); s48_raise_os_error_5 (errno, sec, min, hour, mday, month);