Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src/lib/libutil Pull up following revision(s) (requested by a...
details: https://anonhg.NetBSD.org/src/rev/a908e7cfe686
branches: netbsd-6
changeset: 775643:a908e7cfe686
user: riz <riz%NetBSD.org@localhost>
date: Fri Feb 08 20:30:34 2013 +0000
description:
Pull up following revision(s) (requested by apb in ticket #791):
lib/libutil/parsedate.y: revision 1.13
mktime(3) works in local time, and trying to trick it by
setting tm_gmtoff doesn't work. Instead, call mktime_z(3)
with a null timezone (so it works in UTC) and adjust the
result afterwards. Now "date -d @0" correctly
prints the local equivalent of 1970-01-01 00:00:00 UTC.
diffstat:
lib/libutil/parsedate.y | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diffs (27 lines):
diff -r 4e008ab844a4 -r a908e7cfe686 lib/libutil/parsedate.y
--- a/lib/libutil/parsedate.y Fri Feb 08 20:28:07 2013 +0000
+++ b/lib/libutil/parsedate.y Fri Feb 08 20:30:34 2013 +0000
@@ -590,7 +590,8 @@
DSTMODE DSTmode /* DST on/off/maybe */
)
{
- struct tm tm;
+ struct tm tm = {.tm_sec = 0};
+ time_t result;
/* XXX Y2K */
if (Year < 0)
@@ -611,9 +612,11 @@
case DSToff: tm.tm_isdst = 0; break;
default: tm.tm_isdst = -1; break;
}
- tm.tm_gmtoff = -Timezone;
- return mktime(&tm);
+ /* We rely on mktime_z(NULL, ...) working in UTC, not in local time. */
+ result = mktime_z(NULL, &tm);
+ result -= Timezone;
+ return result;
}
Home |
Main Index |
Thread Index |
Old Index