Module Name: src
Committed By: christos
Date: Wed Apr 17 17:37:29 UTC 2019
Modified Files:
src/lib/libc/time: localtime.c
Log Message:
Pick up the latest matching (most recent) entry instead of the first one.
This fixes:
env TZ=Australia/Melbourne date
printing
Thu Apr 18 03:32:32 LMT 2019
instead of:
Thu Apr 18 03:32:32 AEST 2019
XXX: To be strictly correct, the tzgetname() call should probably take a time
reference point in order to return the appropriate zone name for the time
given.
To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/lib/libc/time/localtime.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/time/localtime.c
diff -u src/lib/libc/time/localtime.c:1.120 src/lib/libc/time/localtime.c:1.121
--- src/lib/libc/time/localtime.c:1.120 Mon Apr 8 14:50:52 2019
+++ src/lib/libc/time/localtime.c Wed Apr 17 13:37:29 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: localtime.c,v 1.120 2019/04/08 18:50:52 christos Exp $ */
+/* $NetBSD: localtime.c,v 1.121 2019/04/17 17:37:29 christos Exp $ */
/* Convert timestamp from time_t to struct tm. */
@@ -12,7 +12,7 @@
#if 0
static char elsieid[] = "@(#)localtime.c 8.17";
#else
-__RCSID("$NetBSD: localtime.c,v 1.120 2019/04/08 18:50:52 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.121 2019/04/17 17:37:29 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -284,15 +284,20 @@ detzcode64(const char *const codep)
return result;
}
+#include <stdio.h>
+
const char *
tzgetname(const timezone_t sp, int isdst)
{
int i;
+ const char *name = NULL;
for (i = 0; i < sp->typecnt; ++i) {
const struct ttinfo *const ttisp = &sp->ttis[i];
if (ttisp->tt_isdst == isdst)
- return &sp->chars[ttisp->tt_abbrind];
+ name = &sp->chars[ttisp->tt_abbrind];
}
+ if (name != NULL)
+ return name;
errno = ESRCH;
return NULL;
}