Boost C++ Libraries: Ticket #7715: Fractional seconds are parsed as timezone https://svn.boost.org/trac10/ticket/7715 <p> We're trying to use Boost's excellent date time functionality, but we've hit a snag. The formatting we require is "%Y-%m-%dT%H:%M:%S.%F%ZP", which results in for example "2012-11-19T23:44:23.122344UTC+1". We use this to store dates and time in our database as a string. </p> <p> The problem seems to be that the %F and %ZP flags don't work well together. The following code generates an exception: </p> <pre class="wiki">std::string serialized = "2012-11-19T23:44:23.122344UTC+1"; std::stringstream ss(serialized); std::string format = "%Y-%m-%dT%H:%M:%S.%F%ZP"; boost::local_time::local_time_facet* facet_output = new boost::local_time::local_time_facet(); facet_output-&gt;format(format.c_str()); ss.imbue(std::locale(std::locale::classic(), facet_output)); boost::local_time::local_time_input_facet* facet_input = new boost::local_time::local_time_input_facet(); facet_input-&gt;format(format.c_str()); ss.imbue(std::locale(ss.getloc(), facet_input)); boost::local_time::local_date_time result(boost::local_time::not_a_date_time); ss &gt;&gt; result; // exception </pre><p> What happens when you trace the stack to the exception is that the tokenizer doesn't see the "122344" bit as fractional seconds and instead thinks it's the timezone. This results in an invalid timezone and thus an exception. </p> <p> We can circumvent the problem by removing the %F flag, but that is an unacceptable workaround, because we need the precision of the fractional seconds. Removing the %F flag solves the problem. </p> <p> The problem was found in 1.48.0, but has not yet been fixed in 1.52.0. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7715 Trac 1.4.3