This is the mail archive of the
libc-hacker@sourceware.cygnus.com
mailing list for the glibc project.
A revised patch for time
- To: libc-hacker@cygnus.com (GNU C Library)
- Subject: A revised patch for time
- From: hjl@lucon.org (H.J. Lu)
- Date: Wed, 28 Oct 1998 13:11:24 -0800 (PST)
There is a problem with my previous time patch. I assumed the daylight
saving adjustment is always 3600. It may not be true. In this patch, I
store the adjustment in __daylight. Since the standard only says a
non-zero value in daylight when the daylight saving time is in effect,
I think it should be ok.
Thanks.
--
H.J. Lu (hjl@gnu.org)
---
Tue Oct 27 21:14:30 1998 H.J. Lu <hjl@gnu.org>
* time/mktime.c (__mktime_internal): Handle tm_isdst == 0
correctly.
* time/tzfile (__tzfile_read): Set __daylight to the difference
between DST and STD.
(__tzfile_compute): Likewise.
* time/tzset.c (tz_compute): Likewise.
Index: mktime.c
===================================================================
RCS file: /home/work/cvs/gnu/glibc/time/mktime.c,v
retrieving revision 1.1.1.13
diff -u -p -r1.1.1.13 mktime.c
--- mktime.c 1998/10/17 02:11:00 1.1.1.13
+++ mktime.c 1998/10/28 17:33:55
@@ -413,7 +413,14 @@ __mktime_internal (tp, convert, offset)
return -1;
}
- *tp = tm;
+ if (isdst == 0 && tm.tm_isdst > 0)
+ {
+ t += __daylight;
+ ranged_convert (convert, &t, tp);
+ }
+ else
+ *tp = tm;
+
return t;
}
Index: tzfile.c
===================================================================
RCS file: /home/work/cvs/gnu/glibc/time/tzfile.c,v
retrieving revision 1.1.1.13
diff -u -p -r1.1.1.13 tzfile.c
--- tzfile.c 1998/10/26 15:33:26 1.1.1.13
+++ tzfile.c 1998/10/28 17:32:31
@@ -298,7 +298,7 @@ __tzfile_read (const char *file)
}
}
- __daylight = rule_stdoff != rule_dstoff;
+ __daylight = rule_dstoff - rule_stdoff;
__timezone = -rule_stdoff;
__use_tzfile = 1;
@@ -436,7 +436,7 @@ __tzfile_compute (time_t timer, int use_
if (use_localtime)
{
struct ttinfo *info = find_transition (timer);
- __daylight = rule_stdoff != rule_dstoff;
+ __daylight = rule_dstoff - rule_stdoff;
__timezone = -rule_stdoff;
__tzname[1] = NULL;
for (i = 0; i < num_types; ++i)
Index: tzset.c
===================================================================
RCS file: /home/work/cvs/gnu/glibc/time/tzset.c,v
retrieving revision 1.1.1.16
diff -u -p -r1.1.1.16 tzset.c
--- tzset.c 1998/10/26 23:24:25 1.1.1.16
+++ tzset.c 1998/10/28 17:34:50
@@ -528,7 +528,7 @@ tz_compute (timer, tm)
&& ! compute_change (&tz_rules[1], 1900 + tm->tm_year + 1))
return 0;
- __daylight = tz_rules[0].offset != tz_rules[1].offset;
+ __daylight = tz_rules[1].offset - tz_rules[0].offset;
__timezone = -tz_rules[0].offset;
__tzname[0] = (char *) tz_rules[0].name;
__tzname[1] = (char *) tz_rules[1].name;