Skip to content

<chrono>: formatter<chrono::year_month_day> is not fully implemented. #2761

@fsb4000

Description

@fsb4000

Describe the bug
At least %x is not implemented.

https://en.cppreference.com/w/cpp/chrono/year_month_day/formatter

Command-line test case

C:\Temp>type main.cpp
#include <chrono>
#include <format>

using namespace std;
using namespace chrono;

int main() {
    const year_month_day date = 2022y / 1 / 1;
    const auto test           = format("{:%x}", date);
    // const auto test = format("{:%D}", date); // works
}

C:\Temp>cl /std:c++20 /EHsc /W4 /WX main.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31424 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

main.cpp
main.cpp(9): error C7595: 'std::_Basic_format_string<char,const std::chrono::year_month_day &>::_Basic_format_string': call to immediate function is not a constant expression
C:\Dev\STL\out\build\x64\out\inc\chrono(5210): note: failure was caused by call of undefined function or one not declared 'constexpr'
C:\Dev\STL\out\build\x64\out\inc\chrono(5210): note: see usage of 'std::_Throw_format_error'

Expected behavior
Should compile without errors.

STL version

https://github.com/microsoft/STL/commit/17fde2cbab6e8724d81c9555237c9a623d7fb954

Additional context
This item is also tracked on Developer Community as Devcom-10061975

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingchronoC++20 chronofixedSomething works now, yay!formatC++20/23 format

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions