title: Parsing Subsecond Date with Howard Hinnant Date Library
body: <p>I have a date string like so <code>YYYYMMDD HHMMSSFFF</code>. I am trying to use Howard Hinnats date library. Snippet of code is like so,</p>
  
  <pre><code>std::chrono::system_clock::time_point tp;
  char date[20] = {0};
  std::istringstream ss{date};
  ss &gt;&gt; date::parse("%Y%m%d %H%M%S%s", tp);
  
  long ts = (std::chrono::time_point_cast&lt;std::chrono::nanoseconds&gt;(tp)
                       .time_since_epoch() /
                   std::chrono::nanoseconds(1));
  </code></pre>
  
  <p>But this code isn't reading the subsecond <code>FFF</code>. I loooked on the documentation <a href="http://howardhinnant.github.io/date/date.html" rel="nofollow noreferrer">here</a> and it states that <code>%s</code> represents fractional of a second time. An example value for date is <code>20170110 103648340</code>. But when I output <code>ts</code> I get 0. If you are wondering why I convert to nanoseconds its because I need the date in nanoseconds for other operations.</p>