# # patch "commands.cc" # from [7291355a92780e10f26eb41272262e52b844e979] # to [29c73be9335e45d126649b36b755f2b2fa6b6214] # --- commands.cc +++ commands.cc @@ -2579,15 +2579,32 @@ { try { - // boost::posix_time is lame: it can parse "basic" ISO times, of the - // form 20000101T120000, but not "extended" ISO times, of the form - // 2000-01-01T12:00:00. So do something stupid to convert one to the - // other. std::string tmp = s; std::string::size_type pos = 0; - while ((pos = tmp.find_first_of("-:")) != string::npos) - tmp.erase(pos, 1); - return boost::posix_time::from_iso_string(tmp); + + if (tmp.find_first_of(" ") != string::npos) + { + // convert space separated date time strings like + // 1996-09-19 20:16:48 to extended ISO time format. + while ((pos = tmp.find_first_of(" ")) != string::npos) + tmp.replace(pos, 1, "T"); + } + + if (tmp.find_first_of("T") != string::npos) + { + // boost::posix_time is lame: it can parse "basic" ISO times, of the + // form 20000101T120000, but not "extended" ISO times, of the form + // 2000-01-01T12:00:00. So do something stupid to convert one to the + // other. + while ((pos = tmp.find_first_of("-:")) != string::npos) + tmp.erase(pos, 1); + + return boost::posix_time::from_iso_string(tmp); + } + else + { + N(false, F("failed to parse date string '%s'") % s); + } } catch (std::out_of_range &e) {