Boost C++ Libraries: Ticket #12449: date_time from string throws exception if time not set https://svn.boost.org/trac10/ticket/12449 <p> There was a bug in parse_iso_time of date_time\time_parsing.hpp in earlier versions of boost. This has been fixed, but the fix does not work if just a date is given (no time set). This is not what I would expect, I would like to get a time set to midnight. My suggestion is to update the fix in split() from </p> <pre class="wiki"> //! Utility function to split appart string inline bool split(const std::string&amp; s, char sep, std::string&amp; first, std::string&amp; second) { std::string::size_type sep_pos = s.find(sep); first = s.substr(0,sep_pos); if (sep_pos!=std::string::npos) second = s.substr(sep_pos+1); return true; } </pre><p> to </p> <pre class="wiki"> //! Utility function to split appart string inline bool split(const std::string&amp; s, char sep, std::string&amp; first, std::string&amp; second) { std::string::size_type sep_pos = s.find(sep); first = s.substr(0,sep_pos); if (sep_pos!=std::string::npos) second = s.substr(sep_pos+1); else // no time set, so we want to get midnight! second = ::std::string("00:00:00"); return true; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12449 Trac 1.4.3 James E. King, III Tue, 26 Dec 2017 22:20:07 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/12449#comment:1 https://svn.boost.org/trac10/ticket/12449#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> The method you are looking for is date_from_iso_string, which only takes YYYYMMDD. parse_iso_time is documented as requiring the full string: </p> <pre class="wiki"> //! Parse time string of form YYYYMMDDThhmmss where T is delimeter between date and time template&lt;class time_type&gt; inline time_type parse_iso_time(const std::string&amp; s, char sep) </pre><p> The code path you describe currently throws std::out_of_range because the code is trying to look at the first character after the "T" and failing, using std::string::at. An exception here is appropriate as the input is invalid; std::invalid_argument or a runtime_error might be more reasonable than a flavor of logic_error, but I don't think it's worth the effort in this case. </p> Ticket