On Wed, 10 Sept 2025 at 16:03, Tomasz Kaminski <tkami...@redhat.com> wrote:
>
>
>
> On Wed, Sep 10, 2025 at 4:57 PM Tomasz Kamiński <tkami...@redhat.com> wrote:
>>
>> libstdc++-v3/ChangeLog:
>>
>>         * testsuite/std/time/year_month_day/io.cc: Additional tests.
>> ---
>> Adding test coverate, before I touch the implementation.
>
> Test test shows that %U/%W computest week count since start of specified year,
> so if you have a date with month outside of range, the weekday will be 
> outside of range.
> This makes sense, as %Y will also input year.
>
> The %V prints week count since ISO year, that is computed, so if your month 
> value
> is out of range, both %G and %U will be updated, but they remain in sync.

Yeah, checking that %V is the previous/next calendar year then an ISO
week-based year disagrees with the Gregorian year is a good addition.

OK for trunk, thanks.


>
>
>>
>> Testing on x86_64-linux locally.
>>  .../testsuite/std/time/year_month_day/io.cc   | 48 +++++++++++--------
>>  1 file changed, 28 insertions(+), 20 deletions(-)
>>
>> diff --git a/libstdc++-v3/testsuite/std/time/year_month_day/io.cc 
>> b/libstdc++-v3/testsuite/std/time/year_month_day/io.cc
>> index 632b7a0fc2d..7c4876fbd01 100644
>> --- a/libstdc++-v3/testsuite/std/time/year_month_day/io.cc
>> +++ b/libstdc++-v3/testsuite/std/time/year_month_day/io.cc
>> @@ -43,38 +43,46 @@ test_format()
>>    s = std::format("{:%G-W%V-%u}", 2022y/January/3);
>>    VERIFY( s == "2022-W01-1" );
>>
>> +  std::chrono::month Quindecember(18);
>>    // %U: Week number for weeks starting on Sunday
>>    s = std::format("Day {:%w (%a) of Week %U of %Y}", 2022y/January/1);
>>    VERIFY( s == "Day 6 (Sat) of Week 00 of 2022" );
>>    s = std::format("Day {:%w (%a) of Week %U of %Y}", 2022y/January/2);
>>    VERIFY( s == "Day 0 (Sun) of Week 01 of 2022" );
>> +  s = std::format("Day {:%w (%a) of Week %U of %Y}", 2022y/Quindecember/20);
>> +  VERIFY( s == "Day 4 (Thu) of Week 77 of 2022" );
>>    // %W: Week number for weeks starting on Monday
>>    s = std::format("Day {:%u (%a) of Week %W of %Y}", 2022y/January/2);
>>    VERIFY( s == "Day 7 (Sun) of Week 00 of 2022" );
>>    s = std::format("Day {:%u (%a) of Week %W of %Y}", 2022y/January/3);
>>    VERIFY( s == "Day 1 (Mon) of Week 01 of 2022" );
>> +  s = std::format("Day {:%w (%a) of Week %U of %Y}", 2022y/Quindecember/20);
>> +  VERIFY( s == "Day 4 (Thu) of Week 77 of 2022" );
>>
>> +  // %G: ISO week-calendar year (ISO 8601)
>>    // %V: ISO week number (ISO 8601).
>> -  s = std::format("W{:%V}", 1977y/1/1);
>> -  VERIFY( s == "W53" );
>> -  s = std::format("W{:%V}", 1977y/1/2);
>> -  VERIFY( s == "W53" );
>> -  s = std::format("W{:%V}", 1977y/12/31);
>> -  VERIFY( s == "W52" );
>> -  s = std::format("W{:%V}", 1978y/1/1);
>> -  VERIFY( s == "W52" );
>> -  s = std::format("W{:%V}", 1978y/1/2);
>> -  VERIFY( s == "W01" );
>> -  s = std::format("W{:%V}", 1978y/12/31);
>> -  VERIFY( s == "W52" );
>> -  s = std::format("W{:%V}", 1979y/1/1);
>> -  VERIFY( s == "W01" );
>> -  s = std::format("W{:%V}", 1979y/12/30);
>> -  VERIFY( s == "W52" );
>> -  s = std::format("W{:%V}", 1979y/12/31);
>> -  VERIFY( s == "W01" );
>> -  s = std::format("W{:%V}", 1980y/1/1);
>> -  VERIFY( s == "W01" );
>> +  s = std::format("{:%G-W%V}", 1977y/1/1);
>> +  VERIFY( s == "1976-W53" );
>> +  s = std::format("{:%G-W%V}", 1977y/1/2);
>> +  VERIFY( s == "1976-W53" );
>> +  s = std::format("{:%G-W%V}", 1977y/12/31);
>> +  VERIFY( s == "1977-W52" );
>> +  s = std::format("{:%G-W%V}", 1978y/1/1);
>> +  VERIFY( s == "1977-W52" );
>> +  s = std::format("{:%G-W%V}", 1978y/1/2);
>> +  VERIFY( s == "1978-W01" );
>> +  s = std::format("{:%G-W%V}", 1978y/12/31);
>> +  VERIFY( s == "1978-W52" );
>> +  s = std::format("{:%G-W%V}", 1979y/1/1);
>> +  VERIFY( s == "1979-W01" );
>> +  s = std::format("{:%G-W%V}", 1979y/12/30);
>> +  VERIFY( s == "1979-W52" );
>> +  s = std::format("{:%G-W%V}", 1979y/12/31);
>> +  VERIFY( s == "1980-W01" );
>> +  s = std::format("{:%G-W%V}", 1980y/1/1);
>> +  VERIFY( s == "1980-W01" );
>> +  s = std::format("{:%G-W%V}", 1980y/18/20);
>> +  VERIFY( s == "1981-W26" );
>>
>>    s = std::format("{:%x}", 2022y/December/19);
>>    VERIFY( s == "12/19/22" );
>> --
>> 2.51.0
>>

Reply via email to