casaroli opened a new pull request, #21019: URL: https://github.com/apache/nuttx/pull/21019
## Summary `strftime()` had no `%Z`: the time zone abbreviation that ISO C and POSIX require printed nothing. `%z` printed a negative offset wrong: -5400 seconds gave `+-130` and -1800 seconds gave `+-030` (a fixed `+` before the signed hours and minutes). This PR adds `%Z` with the other ISO C conversions (`CONFIG_LIBC_STRFTIME_C_STANDARD_FORMATS`): it prints `tm_zone`, which `localtime()` and `gmtime()` set, or nothing when `tm_zone` is NULL. `%z` now prints the sign and the absolute hours and minutes of `tm_gmtoff` (`-0130`). The function comment described `%Z` under `%z`; it now describes both, and the Kconfig help lists `%Z`. ## Impact `%Z` and a negative `%z` change from wrong to correct output. No other conversion changes. Flat, protected and kernel builds use the same libc code. ## Testing Test program `strftime-zone.c` on qemu-armv8a:knsh (QEMU with HVF): `%Z` with "CEST", "NST" and NULL; `%z` with +7200, -5400, -1800 and 0. | | master | this PR | |---|---|---| | `%Z`, tm_zone "CEST" | "" | "CEST" | | `%z`, -5400 s | "+-130" | "-0130" | | `<%Z>`, tm_zone "NST" | "<>" | "<NST>" | | `%z`, -1800 s | "+-030" | "-0030" | | `%z` +7200 s, `%z` 0, `<%Z>` NULL | "+0200", "+0000", "<>" | the same | | result | 4 of 7 FAIL | PASS | ostest exits with status 0 on qemu-armv8a:knsh and qemu-armv8a:nsh. Build, each OK: qemu-armv8a:nsh (flat, arm64), qemu-armv8a:knsh (kernel, arm64), rv-virt:nsh64 (flat, rv64), rv-virt:pnsh64 (protected, rv64), rv-virt:knsh64 (kernel, rv64), and qemu-armv8a:nsh without `CONFIG_LIBC_STRFTIME_C_STANDARD_FORMATS` and `CONFIG_LIBC_STRFTIME_POSIX_FORMATS`. `tools/checkpatch.sh -c -u -m -g` passes. No documentation change: the documentation does not list the `strftime()` conversions (`Documentation/standards/posix.rst` has only "strftime() Yes"). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
