title: Casting time_points between std::chrono clocks
body: <p>The title line of this post is really only one half (the simpler half) of my question. So, I'll step back a moment to talk about what I'm trying to do.</p>
  
  <p>It's pretty easy to measure elapsed time with <code>std::chrono</code>. However, I haven't seen any "Timer" implementations thus far that would do the equivalent of laps on a stopwatch. That is to say, you call <code>Timer.start()</code> when you want to start tracking intervals, and call <code>Timer.tick()</code> every time you want to record an interval. Then, after the fast stuff is over, you could look back on the list of time intervals recorded; maybe account for averages and 1% highs or something.</p>
  
  <p>Also, because I use it a lot, I'd want to arbitrarily ask the timer how many microseconds have elapsed since midnight.</p>
  
  <p>The first task for a constructor for this imaginary class would be to set midnight internally. Initially, I was doing this via the technique from <a href="https://stackoverflow.com/a/11123391/1464937">this</a> wonderful answer. As I went to implement my notion of a <code>Timer</code> class, though, I realized I wanted to use either <code>high_resolution_clock</code> or <code>steady_clock</code> (even though <code>system_clock</code> uses nanosecond intervals on my platform). The issue then arises: how to set a <code>chrono::steady_clock::time_point</code> to midnight?</p>
  
  <p>Only <code>system_clock</code> has <code>to_time_t</code> and <code>from_time_t</code>, and in so far as I can tell, that's the only way to express "today at midnight" in a way that <code>chrono</code> understands. And for all my reading last night, I couldn't find a way to cast a <code>system_clock::time_point</code> to a <code>steady_clock::time_point</code>. My nearest attempt was:</p>
  
  <pre><code>typedef std::conditional&lt;std::chrono::high_resolution_clock::is_steady,
                           std::chrono::high_resolution_clock,
                           std::chrono::steady_clock&gt;::type TimerClock;
  
  TimerClock::time_point midnight;
  
  chrono::system_clock::time_point current_time = chrono::system_clock::now();
  
  time_t raw_time = chrono::system_clock::to_time_t(current_time);
  
  tm *tm_midnight = localtime(&amp;raw_time);
  tm_midnight-&gt;tm_hour = 0;
  tm_midnight-&gt;tm_min  = 0;
  tm_midnight-&gt;tm_sec  = 0;
  
  midnight = chrono::system_clock::from_time_t(mktime(tm_midnight));
  </code></pre>
  
  <p>But obviously that won't fly. And in so far as I can tell, <code>chrono::time_point_cast</code> is designed to give you access to different resolutions from the same clock type.</p>
  
  <p>This leaves me with two routes/questions:</p>
  
  <ul>
  <li>Can I directly set the value of a <code>time_point</code> from <code>high_precision_clock</code> or <code>steady_clock</code> to be "today at midnight"</li>
  <li>Can I convert a <code>system_clock::time_point</code> to be used with a different <code>chrono</code> clock?</li>
  </ul>
  
  <p>And, of course, I'd be happy to be pointed to a better method of dealing with this all together, if it still lines up with my overall goals above.</p>
  
  <p>Thanks in advance. =)</p>