https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117085
Bug ID: 117085
Summary: chrono formatting: %c does not honor locale after
expansion
Product: gcc
Version: 14.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: xu2k3l4 at outlook dot com
Target Milestone: ---
## issue description
how to reproduce:
```cpp
#include <chrono>
#include <locale>
#include <print>
constexpr const char *localename = "zh_CN.UTF-8";
int main()
{
std::locale locale(localename);
std::locale::global(locale);
auto timepoint = std::chrono::system_clock::from_time_t(0);
std::println("{:L%c}", timepoint);
}
```
output (x86_64-pc-linux-gnu gcc 14.2.0), note that "Thursday" is not localized:
```plaintext
1970年01月01日 Thursday 00时00分00秒
```
expected output, i.e. `TZ= LANG=zh_CN.UTF-8 date +'%c' --date='@0'` produces:
```plaintext
1970年01月01日 星期四 00时00分00秒
```
(same issue exists for many other locales, like fr_FR outputting "Thu 01 Jan
1970 00:00:00" instead of expected "jeu. 01 janv. 1970 00:00:00")
## analysis
`__formatter_chrono::_M_c` passes local time format ("%Y年%m月%d日 %A %H时%M分%S秒"
for zh_CN) to sub-`vformat_to`, but without "L" format specifier the
sub-`vformat_to` will not format the "%A" with requested locale.
code link:
`__formatter_chrono::_M_c` construction of format string.
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/include/bits/chrono_io.h;h=652e88ffe3abbfa78b769c70c3efbae9207a9804;hb=HEAD#l904
## possible solution
in `__formatter_chrono::_M_c`, `__fmt.insert` 'L' if needed.