summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2003-12-14 23:51:30 +0000
committerManuel Novoa III <mjn3@codepoet.org>2003-12-14 23:51:30 +0000
commit5cebc517751c48c46022b2ee529659307a94d628 (patch)
tree1c7294dab856537452b98307a56ebc7a16140750 /libc
parentedcbb2ecce1455995c5990fb5f39d14881b809fa (diff)
downloaduClibc-alpine-5cebc517751c48c46022b2ee529659307a94d628.tar.bz2
uClibc-alpine-5cebc517751c48c46022b2ee529659307a94d628.tar.xz
Fix some dst issues in _time_mktime().
Normalize the tm_isdst value to -1, 0, or 1. If no dst for this timezone, then reset tm_isdst to 0.
Diffstat (limited to 'libc')
-rw-r--r--libc/misc/time/time.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c
index 69e688b40..be3216423 100644
--- a/libc/misc/time/time.c
+++ b/libc/misc/time/time.c
@@ -128,6 +128,10 @@
* Fix a dst-related bug which resulted in use of uninitialized data.
*
* Nov 15, 2003 I forgot to update the thread locking in the last dst fix.
+ *
+ * Dec 14, 2003 Fix some dst issues in _time_mktime().
+ * Normalize the tm_isdst value to -1, 0, or 1.
+ * If no dst for this timezone, then reset tm_isdst to 0.
*/
#define _GNU_SOURCE
@@ -2108,11 +2112,14 @@ time_t _time_mktime(struct tm *timeptr, int store_on_success)
memcpy(p, timeptr, sizeof(struct tm));
- if ((default_dst = p[8]) < 0) { /* Try to determing if dst? */
- default_dst = 1; /* Assume advancing. */
- if (!_time_tzinfo[1].tzname[0]) { /* Oops... no dst. */
- default_dst = p[8] = 0;
- }
+ if (!_time_tzinfo[1].tzname[0]) { /* No dst in this timezone, */
+ p[8] = 0; /* so set tm_isdst to 0. */
+ }
+
+ default_dst = 0;
+ if (p[8]) { /* Either dst or unknown? */
+ default_dst = 1; /* Assume advancing (even if unknown). */
+ p[8] = ((p[8] > 0) ? 1 : -1); /* Normalize so abs() <= 1. */
}
d = 400;