In C++20, <chrono> has been extended by the Howard Hinant date library but some things are missing

Hi,

Although it is nice that <chrono> has been extended, there are some functions that I haven't found after looking intensely...

For example conversion from std::chrono::sys_days to std::string should be doable by usign the new fmtlib, like so:

1
2
3
4
5
6
7
8
std::string DatePointToString( std::chrono::sys_date pt)
{
// was: auto ret = date::format("%F", pt);  //STILL WORKS as long as date.h is 
                                            //available 
// now: auto ret = std::format("%F", pt;   // DOES NOT WORK

return ret;
}


On the other direction, from string to sys_days it works like a charm:

1
2
  std::chrono::sys_days tt;
  auto ret =  std::chrono::parse("%F"s, tt);


So any thing I am missing?

Regards,
Juan
1
2
//You meant:
auto ret = std::format("%F", pt);


Make sure you have the #include <format> header. If it isn't working, then your environment isn't updated with these things yet. You probably just have to wait.
Last edited on
Might help if you give your exact compiler version so that one could lookup what C++20 features it has support for.
C++ version support for the major compilers is at https://en.cppreference.com/w/cpp/compiler_support

Currently, std::format is only available with MS VS2019 16.10 (released a couple of days ago).
Last edited on
Topic archived. No new replies allowed.