https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120481

--- Comment #1 from Tomasz KamiƄski <tkaminsk at gcc dot gnu.org> ---
Similar issue appears also for using '%w' and '%u' on the weekday that contains
a 2 or 3 digit number:
```
std::cout << std::format("{:%w}", weekday(120)) << std::endl; // prints 8
std::cout << std::format("{:%u}", weekday(120)) << std::endl; // prints 8
std::cout << std::format("{:%w}", weekday(11)) << std::endl; // prints 8
std::cout << std::format("{:%u}", weekday(11)) << std::endl; // prints 9
``

However, in this case the standard specifies that the result should be in
range:
%u
The calendar day of week as a decimal number (1-7), as specified in ISO
8601-1:2019, where Monday is 1.
The modified command %Ou produces the locale's alternative representation.

%w
The weekday as a decimal number (0-6), where Sunday is 0.
The modified command %Ow produces the locale's alternative representation.

We should consider either throwing an exception if wd is not valid, or apply %
arithmetic.

Reply via email to