bug-gawk
[Top][All Lists]
Advanced

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

Gawk strftime problem under MacOS Ventura using %z format with utc-flag


From: Stuart Ferguson
Subject: Gawk strftime problem under MacOS Ventura using %z format with utc-flag set
Date: Fri, 23 Jun 2023 21:25:04 +0100

Attestation 1:

I have read https://www.gnu.org/software/gawk/manual/html_node/Bugs.html
-- Yes.

Attestation 2:

I have not modified the sources before building gawk.
-- True.

Description:

I ran the following script under a number of different operating systems:

BEGIN {
  unixTime = 1687531200
  split("America/Chicago Europe/Berlin Asia/Kolkata", tz)

  for (str in tz) {
    ENVIRON["TZ"] = tz[str]
    for (utcFlag = 0; utcFlag <= 1; utcFlag++) {
      print strftime("%F %T %Z %z", unixTime, utcFlag), utcFlag
    }
  }
}

Under MacOS Ventura (Test case 1, below), the strftime %z output appears to
be
incorrect when utc-flag (using Gawk manual terminology) is set. Notice the
discrepancy: %Z output is "UTC", but %z is NOT "+0000".

What appears to be happening is that utc-flag is altering the %z output for
daylight saving time, not setting %z output to "+0000". I have confirmed
this
outcome (not documented here) by running the script with a Unix time
corresponding to winter in the Northern hemisphere, when DST is not in
effect.

Running the script under Ubuntu 23.04 (Test case 2) and Alpine Linux 3.18
(Test case 3) does not exhibit the same problem. In each case, %Z output of
"UTC" or "GMT" corresponds to %z output of "+0000".

I'm afraid I don't have a suggestion to fix the problem. Nevertheless, I
hope
this bug report is useful.

Stuart

---------------------------------------

Test case 1: MacOS Ventura 13.4.1

Configuration Information ---
Machine: aarch64
OS: darwin22.4.0
Compiler: clang
Compilation CFLAGS: -g -O2 -DNDEBUG
uname output: Darwin Stuarts-MacBook-Air.local 22.5.0 Darwin Kernel Version
22.5.0: Thu Jun  8 22:22:19 PDT 2023;
root:xnu-8796.121.3~7/RELEASE_ARM64_T8103 arm64
Machine Type: aarch64-apple-darwin22.4.0
Gawk Version: 5.2.2

Script output ---
2023-06-23 09:40:00 CDT -0500 0
2023-06-23 14:40:00 UTC -0600 1
2023-06-23 16:40:00 CEST +0200 0
2023-06-23 14:40:00 UTC +0100 1
2023-06-23 20:10:00 IST +0530 0
2023-06-23 14:40:00 UTC +0530 1

---------------------------------------

Test case 2: Ubuntu 23.04

Configuration Information ---
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -ffile-prefix-map=/build/gawk-eXJnST/gawk-5.2.1=.
-flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat
-Werror=format-security
-fdebug-prefix-map=/build/gawk-eXJnST/gawk-5.2.1=/usr/src/gawk-1:5.2.1-2
-DNDEBUG
uname output: Linux Pk2 6.2.0-20-generic #20-Ubuntu SMP PREEMPT_DYNAMIC Thu
Apr 6 07:48:48 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Gawk Version: 5.2.1

Script output ---
2023-06-23 09:40:00 CDT -0500 0
2023-06-23 14:40:00 GMT +0000 1
2023-06-23 16:40:00 CEST +0200 0
2023-06-23 14:40:00 GMT +0000 1
2023-06-23 20:10:00 IST +0530 0
2023-06-23 14:40:00 GMT +0000 1

---------------------------------------

Test case 3: Alpine Linux 3.18

Configuration Information ---
Machine: i586
OS: linux-musl
Compiler: gcc
Compilation CFLAGS: -Os -Wformat -Werror=format-security -flto=auto -DNDEBUG
uname output: Linux Stuarts-iPhone-2 4.20.69-ish SUPER AWESOME May 20 2023
23:41:32 i686 Linux
Machine Type: i586-alpine-linux-musl
Gawk Version: 5.2.2

Script output ---
2023-06-23 09:40:00 CDT -0500 0
2023-06-23 14:40:00 UTC +0000 1
2023-06-23 16:40:00 CEST +0200 0
2023-06-23 14:40:00 UTC +0000 1
2023-06-23 20:10:00 IST +0530 0
2023-06-23 14:40:00 UTC +0000 1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]