Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/time Change the way that we compute the time when w...
details: https://anonhg.NetBSD.org/src/rev/012132f08276
branches: trunk
changeset: 771089:012132f08276
user: christos <christos%NetBSD.org@localhost>
date: Tue Nov 08 18:37:31 2011 +0000
description:
Change the way that we compute the time when we fall in the dst gap: instead
of supplying just the high bound and thus losing minutes and seconds, add
the DST offset to the struct tm (since we know we are going to move ahead
since we fell in the gap), and try again.
diffstat:
lib/libc/time/localtime.c | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
diffs (58 lines):
diff -r 59196b2db86a -r 012132f08276 lib/libc/time/localtime.c
--- a/lib/libc/time/localtime.c Tue Nov 08 17:16:52 2011 +0000
+++ b/lib/libc/time/localtime.c Tue Nov 08 18:37:31 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: localtime.c,v 1.63 2011/11/07 19:42:03 christos Exp $ */
+/* $NetBSD: localtime.c,v 1.64 2011/11/08 18:37:31 christos Exp $ */
/*
** This file is in the public domain, so clarified as of
@@ -10,7 +10,7 @@
#if 0
static char elsieid[] = "@(#)localtime.c 8.17";
#else
-__RCSID("$NetBSD: localtime.c,v 1.63 2011/11/07 19:42:03 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.64 2011/11/08 18:37:31 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -1802,6 +1802,9 @@
*okayp = FALSE;
yourtm = *tmp;
+#ifdef NO_ERROR_IN_DST_GAP
+again:
+#endif
if (do_norm_secs) {
if (normalize_overflow(&yourtm.tm_min, &yourtm.tm_sec,
SECSPERMIN))
@@ -1919,23 +1922,20 @@
--hi;
}
#ifdef NO_ERROR_IN_DST_GAP
- if (ilo != lo && lo - 1 == hi && yourtm.tm_isdst < 0) {
- time_t off = 0;
+ if (ilo != lo && lo - 1 == hi && yourtm.tm_isdst < 0 &&
+ do_norm_secs) {
for (i = sp->typecnt - 1; i >= 0; --i) {
for (j = sp->typecnt - 1; j >= 0; --j) {
+ time_t off;
if (sp->ttis[j].tt_isdst ==
sp->ttis[i].tt_isdst)
continue;
off = sp->ttis[j].tt_gmtoff -
sp->ttis[i].tt_gmtoff;
- break;
+ yourtm.tm_sec += off < 0 ?
+ -off : off;
+ goto again;
}
- if (j >= 0)
- break;
- }
- if (off) {
- t = hi;
- break;
}
}
#endif
Home |
Main Index |
Thread Index |
Old Index