This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Another time patch


That is the one found out by VSX-PCT. I got

# gcc t.c
# TZ=GMT0BST,J81,J300 a.out 0
min: 59
hour: 0
isdst: 1
593913599
Thu Oct 27 00:59:59 1988
# TZ=GMT0BST,J81,J300 a.out 1
min: 59
hour: 1
isdst: 0
593920799
Thu Oct 27 01:59:59 1988

It should be:

# TZ=GMT0BST,J81,J300 a.out 0
min: 59
hour: 1
isdst: 1
593917199
Thu Oct 27 01:59:59 1988
# TZ=GMT0BST,J81,J300 a.out 1
min: 59
hour: 1
isdst: 0
593920799
Thu Oct 27 01:59:59 1988

Ulrich, could you please double check it?

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.

Index: time/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 05:08:48
@@ -413,7 +413,14 @@ __mktime_internal (tp, convert, offset)
 	return -1;
     }
 
-  *tp = tm;
+  if (isdst == 0 && tm.tm_isdst > 0)
+    {
+      t += 3600;
+      ranged_convert (convert, &t, tp);
+    }
+  else
+    *tp = tm;
+
   return t;
 }
 
----
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

main (int argc, char **argv)
{
  struct tm x;
  time_t t;

  x.tm_sec = 59;
  x.tm_min = 59;
  x.tm_hour = atol (argv [1]);
  x.tm_mday = 27;
  x.tm_mon = 9;
  x.tm_year = 88;
  x.tm_isdst = 0;
  t = mktime (&x);
  printf ("min: %d\n", x.tm_min);
  printf ("hour: %d\n", x.tm_hour);
  printf ("isdst: %d\n", x.tm_isdst);
  printf ("%u\n", t);
  printf ("%s", ctime (&t));
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]