From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: nstrftime %c bug w.r.t. time zone
Date: Thu, 08 Feb 2024 01:04:34 +0100 [thread overview]
Message-ID: <3217691.vfdyTQepKt@nimes> (raw)
Hi Paul,
time.in.h says:
(timezone_t) NULL stands for UTC.
However, nstrftime, on NetBSD 7 and Solaris 11, prints my local time zone
("CET"), not "UTC" or "GMT", in this test program:
================================== foo.c =================================
#include <config.h>
#include <assert.h>
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "strftime.h"
int main ()
{
setlocale (LC_ALL, "fr_FR.UTF-8");
time_t t = 1509000003;
struct tm *tm = gmtime (&t);
int ns = 123456789;
char buf[100];
size_t n;
n = nstrftime (buf, sizeof buf, "%+4Y-%m-%d %H:%M:%S.%N", tm, 0, ns);
assert (n > 0);
printf ("Format as ISO 8601: %s\n", buf);
assert (strcmp (buf, "2017-10-26 06:40:03.123456789") == 0);
n = nstrftime (buf, sizeof buf, "%c", tm, 0, ns);
assert (n > 0);
printf ("%%c directive: %s\n", buf);
}
/* Output on
NetBSD 7.1: 26 octobre 2017 06:40:03 CET
Solaris 11.4: 26 octobre 2017 à 06:40:03 CET
*/
============================================================================
How to run it:
- Use a testdir that contains module 'nstrftime'.
- Build it.
- $ gcc -Wall foo.c -I. -Igllib -I../gllib gllib/libgnu.a
$ ./a.out
Another way to reproduce it:
1. Create a testdir for module 'nstrftime'.
2. Transport it to a NetBSD or Solaris system.
3. Run it. Result: test-nstrftime-2.sh fails at test-nstrftime.h:421.
Bruno
next reply other threads:[~2024-02-08 0:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-08 0:04 Bruno Haible [this message]
2024-02-08 11:50 ` nstrftime %c bug w.r.t. time zone Bruno Haible
2024-02-08 13:55 ` Bruno Haible
2024-02-09 7:36 ` Paul Eggert
2024-02-09 10:10 ` Bruno Haible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3217691.vfdyTQepKt@nimes \
--to=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).