[Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX

2025-07-15 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

Jonathan Wakely  changed:

   What|Removed |Added

 Target|*-*aix* *-*-mingw*  |*-*aix*
Summary|std::chrono::current_zone() |std::chrono::current_zone()
   |doesn't work on AIX or  |doesn't work on AIX
   |Windows |

--- Comment #9 from Jonathan Wakely  ---
It should work for Windows now

[Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX or Windows

2025-07-15 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

--- Comment #8 from GCC Commits  ---
The master branch has been updated by Jonathan Wakely :

https://gcc.gnu.org/g:e28494e08092c4096a015563c0ba0494ce1edf81

commit r16-2267-ge28494e08092c4096a015563c0ba0494ce1edf81
Author: Björn Schäpers 
Date:   Thu Jul 10 09:48:19 2025 +0200

libstdc++: Implement std::chrono::current_zone() for Windows [PR108409]

On Windows there is no API to get the current time zone as IANA name,
instead Windows has its own zones. But there exists a mapping provided
by the Unicode Consortium. This patch adds a script to convert the XML
file with the mapping to a lookup table and adds a Windows code path to
use that mapping.

libstdc++-v3/Changelog:

Implement std::chrono::current_zone() for Windows

PR libstdc++/108409
* scripts/gen_windows_zones_map.py: New file, generates
windows_zones-map.h.
* src/c++20/windows_zones-map.h: New file, contains the look up
table.
* src/c++20/tzdb.cc (tzdb::current_zone): Add Windows code path.

Signed-off-by: Björn Schäpers 

[Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX or Windows

2023-11-06 Thread mac at mcrowe dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

Mike Crowe  changed:

   What|Removed |Added

 CC||mac at mcrowe dot com

--- Comment #7 from Mike Crowe  ---
ICU tries to solve this problem with a table at
https://github.com/unicode-org/icu/blob/fa6a4661ba002c1c1ee68cbf5c7ac9af75132d07/icu4c/source/common/putil.cpp#L802
and other heuristics in the same file.

Based on my understanding, the table is incorrect for the Australian zones and
US/Aleutian (it gets the short names wrong) and it's missing the non-DST US
zones.

I'm not sure if it's worth going to these lengths to try to map POSIX time zone
strings to Olson names, but I thought I'd provide the link in case it's useful.

[Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX

2023-01-15 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

--- Comment #6 from Jonathan Wakely  ---
https://learn.microsoft.com/en-gb/windows/win32/api/timezoneapi/nf-timezoneapi-getdynamictimezoneinformation?redirectedfrom=MSDN
has the same problem. I guess this is why MSVC uses ICU for its
std::chrono::tzdb implementation.

[Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX

2023-01-15 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

--- Comment #5 from Jonathan Wakely  ---
(In reply to Jonathan Wakely from comment #4)
> The current code doesn't work on Windows either.

https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-gettimezoneinformation
only gives us the abbreviated names of the standard and daylight zones, e.g.
"EST" and "EDT". But those names are not unique and cannot be used to map to a
time zone, as the C++ standard points out in [time.zone.info.sys] p6:

"Abbreviations are not unique among the time_zones, and so one cannot reliably
map abbreviations back to a time_zone and UTC offset."

[Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX

2023-01-15 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

--- Comment #4 from Jonathan Wakely  ---
The current code doesn't work on Windows either.

[Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX

2023-01-14 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

--- Comment #3 from Jonathan Wakely  ---
(In reply to Jonathan Wakely from comment #0)
> We should parse the TZ env var and see if it is already an IANA name, and
> handle a few other special cases. E.g. gcc119 in the cfarm hax TZ=CUT0 which
> means a time zone named "CUT" (coordinated universal time) with a 0 offset
> from UTC. So map to UTC. More generally, "FOOn" is a time zone called "FOO"
> with a -n offset, so we could map any such string to "Etc/GMT-n"

It now works if TZ contains an IANA time zone name, or any string matching
"???0". If the systemwide TZ isn't one of those, users can define TZ for their
own programs' environment.

I don't know if that's good enough.

[Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX

2023-01-14 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

--- Comment #2 from CVS Commits  ---
The master branch has been updated by Jonathan Wakely :

https://gcc.gnu.org/g:d80e5a7b30e5d045c808f5235123e366e4e9286c

commit r13-5170-gd80e5a7b30e5d045c808f5235123e366e4e9286c
Author: Jonathan Wakely 
Date:   Sat Jan 14 20:13:32 2023 +

libstdc++: Implement std::chrono::current_zone() for AIX [PR108409]

libstdc++-v3/ChangeLog:

PR libstdc++/108409
* src/c++20/tzdb.cc (current_zone()) [_AIX]: Use TZ environment
variable.

[Bug libstdc++/108409] std::chrono::current_zone() doesn't work on AIX

2023-01-14 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108409

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
   Last reconfirmed||2023-01-14

--- Comment #1 from Jonathan Wakely  ---
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03
describes the format of the TZ variable when it's not an IANA name.

When TZ does not name an IANA zone, we could potentially create a new
chrono::time_zone object, generated from the std and dst names, with the
appropriate offsets and DST transitions. Then current_zone() would return a
pointer to that custom zone.