Jonathan Wakely
778c28c70f
libstdc++: Fix localized %c formatting for non-UTC times [PR117214]
...
The previous commit fixed most cases of %c formatting, but it
incorrectly prints times using the system's local time zone. This only
matters if the locale's %c format includes %Z, but some do.
To print a correct value for %Z we can set tm.tm_zone to either "UTC" or
the abbreviation passed to the formatter in the local-time-format-t
structure.
For local times with no info and for systems that don't support tm_zone
(which is new in POSIX.1-2024) we just set tm_isdst = -1 so that no zone
name is printed.
In theory, a locale's %c format could use %z which should print a +hhmm
offset from UTC. I'm unsure how to control that though. The new
tm_gmtoff field in combination with tm_isdst != -1 seems like it should
work, but using that without also setting tm_zone causes the system zone
to be used for %Z again. That means local_time_format(lt, nullptr, &off)
might work for a locale that uses %z but prints the wrong thing for %Z.
This commit doesn't set tm_gmtoff even if _M_offset_sec is provided for
a local-time-format-t value.
libstdc++-v3/ChangeLog:
PR libstdc++/117214
* configure.ac: Use AC_STRUCT_TIMEZONE.
* config.h.in: Regenerate.
* configure: Regenerate.
* include/bits/chrono_io.h (__formatter_chrono::_M_c): Set
tm_isdst and tm_zone.
* testsuite/std/time/format/pr117214.cc: Check %c formatting of
zoned_time and local time.
2025-03-21 10:28:16 +00:00
..
2025-02-25 22:34:24 +00:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-02-22 21:20:19 +00:00
2025-01-10 21:06:21 +00:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-03-06 14:40:58 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-03-21 10:28:16 +00:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-08 12:45:37 +00:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-02-25 22:27:14 +01:00
2025-03-18 15:12:53 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-02-28 21:48:01 +00:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-08 12:45:37 +00:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-03-19 23:29:06 +00:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2024-09-25 08:20:45 -04:00
2025-01-08 12:45:39 +00:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-02-07 14:53:30 +00:00
2025-01-02 11:59:57 +01:00
2024-09-25 08:20:45 -04:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-02-15 10:58:56 +00:00
2025-02-25 22:34:24 +00:00
2025-02-28 21:35:27 +00:00
2025-03-19 14:49:22 +01:00
2025-01-02 11:59:57 +01:00
2025-03-05 09:58:29 +01:00
2025-03-12 10:12:36 +00:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-08 12:45:37 +00:00
2025-01-02 11:59:57 +01:00
2024-09-25 08:20:45 -04:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-03-14 10:52:07 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-03-05 17:59:18 +01:00
2025-03-08 10:39:56 +00:00
2025-01-31 15:53:10 -05:00
2025-03-05 09:58:29 +01:00
2025-01-08 12:45:37 +00:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-02-28 09:39:57 -05:00
2025-03-06 16:17:34 +00:00
2025-03-18 13:07:00 +01:00
2025-03-18 13:07:00 +01:00
2025-03-18 14:44:11 +01:00
2025-01-02 11:59:57 +01:00
2025-03-06 12:24:47 +01:00
2025-03-13 16:48:56 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-03-18 14:44:11 +01:00
2025-03-13 16:48:56 +01:00
2025-01-02 11:59:57 +01:00
2025-02-14 15:33:12 +00:00
2025-03-05 09:58:29 +01:00
2025-03-21 10:28:06 +00:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2024-03-19 15:20:07 +00:00
2025-01-02 11:59:57 +01:00
2024-10-08 10:01:47 +02:00
2024-11-11 18:57:16 +00:00
2025-01-02 11:59:57 +01:00
2025-03-06 16:46:19 +00:00
2025-03-12 10:12:36 +00:00
2025-03-19 13:52:32 +01:00
2025-03-19 13:52:32 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-02 11:59:57 +01:00
2025-01-31 15:53:10 -05:00
2025-03-12 16:09:42 -04:00
2025-03-12 16:09:42 -04:00
2025-01-02 11:59:57 +01:00