So I have this piece of code:
auto time_now = std::chrono::system_clock::now();
auto time_delta = duration->to_seconds();
auto future = time_now + time_delta;
auto future_str = std::format("{}", future);
However, in the last line, I get the following error:
In template: call to deleted constructor of 'typename format_context::formatter_type<time_point<system_clock, duration<long long, ratio<1, 1000000>>>>' (aka 'formatter<std::chrono::time_point<std::chrono::system_clock, std::chrono::duration<long long, std::ratio<1, 1000000>>>, char>') error occurred here while substituting into a lambda expression here in instantiation of function template specialization 'std::basic_format_arg<std::format_context>::handle::handle<std::chrono::time_point<std::chrono::system_clock>>' requested here in instantiation of function template specialization 'std::basic_format_arg<std::format_context>::basic_format_arg<std::chrono::time_point<std::chrono::system_clock>>' requested here in instantiation of function template specialization 'std::make_format_args<std::format_context, std::chrono::time_point<std::chrono::system_clock>>' requested here in instantiation of function template specialization 'std::format<std::chrono::time_point<std::chrono::system_clock>>' requested here 'formatter' has been explicitly marked deleted here
I'm aware that I have to set a time format for it (per this SO post and this one), however doing any of those (i.e std::format("{:%Y-%m-%d %X}", future);) doesn't make the error disappear.
Stack Overflow
Let's assume we have a simple function that takes a std::chrono::time_point and returns a string using a given formatting string. Like so:
std::string DateTimeToString(std::chrono::sys_time, const ...