Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/time Pick up the latest matching (most recent) entr...



details:   https://anonhg.NetBSD.org/src/rev/e9e2ff9902be
branches:  trunk
changeset: 450553:e9e2ff9902be
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Apr 17 17:37:29 2019 +0000

description:
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.

diffstat:

 lib/libc/time/localtime.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (40 lines):

diff -r 96d4fcb4ec2a -r e9e2ff9902be lib/libc/time/localtime.c
--- a/lib/libc/time/localtime.c Wed Apr 17 16:45:38 2019 +0000
+++ b/lib/libc/time/localtime.c Wed Apr 17 17:37:29 2019 +0000
@@ -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 @@
        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;
 }



Home | Main Index | Thread Index | Old Index