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




Reply via email to