Subject: lib/10950: strftime(3) ignores tm_zone when processing %Z
To: None <gnats-bugs@gnats.netbsd.org>
From: Takahiro Kambe <taca@sky.yamashina.kyoto.jp>
List: netbsd-bugs
Date: 09/04/2000 22:49:16
>Number: 10950
>Category: lib
>Synopsis: strftime(3) ignores tm_zone when processing %Z
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Sep 04 22:50:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Takahiro Kambe
>Release: NetBSD 1.5_ALPHA2 (2000/9/3)
>Organization:
>Environment:
System: NetBSD edge.sky.yamashina.kyoto.jp 1.5_ALPHA2 NetBSD 1.5_ALPHA2 (CF-M33) #58: Sat Aug 19 23:58:06 JST 2000 taca@edge.sky.yamashina.kyoto.jp:/usr/src/sys/arch/i386/compile/CF-M33 i386
>Description:
strftime(3) ignores tm_zone filed of last parameter, struct tm *
when processing %Z in format string.
>How-To-Repeat:
A sample program is bellow.
#include <stdio.h>
#include <time.h>
main()
{
time_t t;
struct tm *tm;
char buf[BUFSIZ];
tzset();
time(&t);
tm = gmtime(&t);
printf("%-10s tm_zone: %s, ", "gmtime", tm->tm_zone);
if (strftime(buf, sizeof buf, "%Z", tm))
printf("strftime %%Z: %s\n", buf);
tm = localtime(&t);
printf("%-10s tm_zone: %s, ", "localtime", tm->tm_zone);
if (strftime(buf, sizeof buf, "%Z", tm))
printf("strftime %%Z: %s\n", buf);
}
This program output:
gmtime tm_zone: GMT, strftime %Z: JST
localtime tm_zone: JST, strftime %Z: JST
If it might be spec of ANSI X3.159-1989 ("ANSI C"), but this make
%Z format string much useless.
>Fix:
Fix strftime(3) to honor tm_zone filed.
>Release-Note:
>Audit-Trail:
>Unformatted: