title: Convert time_point to string using std::format with format that includes date, time and subseconds
body: <p>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:</p>
  <pre><code>std::string DateTimeToString(std::chrono::sys_time, const char * szFormat /*= &quot;%Y/%m/%d %H:%M:%S&quot;*/)
  </code></pre>
  <p>According to the cppreference documentation of <a href="https://en.cppreference.com/w/cpp/chrono/system_clock/formatter" rel="nofollow noreferrer">std::formatter</a> we should be able to use the individual tags to create a string like <code>2021/03/24 15:36:32.123123</code>. However, when the duration of the time_point uses microseconds (which is mandatory for our use) then this throws a format_error.</p>
  <p>If we split this into to separate calls so that we use format for the date and time separately then it works. Like this:</p>
  <pre><code>auto tSysTime = std::chrono::system_clock::now();
  std::string sTime = std::format(&quot;{:%H:%M:%S}&quot;, tSysTime.time_since_epoch());
  std::string sDate = std::format(&quot;{:%Y/%m/%d}&quot;, std::chrono::sys_days(std::chrono::duration_cast&lt;std::chrono::days&gt;(tSysTime.time_since_epoch())));
  </code></pre>
  <p>Am I missunderstanding something or is there no way to have a single format string for my purpose? Keep in mind that the format string is an optional parameter so I cannot hardcode a split of individual parameters.</p>
  <p>My expection would be to write</p>
  <pre><code>std::format(&quot;{:%Y/%m/%d %H:%M:%S}&quot;,tSysTime.time_since_epoch());
  </code></pre>
  <p>However, this crashes...</p>
  <p>Thank you in advance for any help!</p>
  <p>Edit: I'm using /std::c++latest flag in Visual Studio 2019</p>