# # patch "commands.cc" # from [177acfa9bb2a5e8a8eca4b8dd87b7e0feef7ff5b] # to [22f3729ba21c7f3278e5941b1b589da4b9e9910c] # # patch "git_export.cc" # from [f2ea7c4e976be2e6ee857643ae941936d597ab53] # to [6dca3d75647ad2085c497fe99f245c2c0252f75e] # # patch "transforms.cc" # from [05437d611e11ac3f6a0cbef9eb352a112c60d401] # to [a5d73bf198e5007709b22a4b69d09c9cb574cefb] # # patch "transforms.hh" # from [934c5f0c68d4ee8c18a2237398d43a59107e067a] # to [09dd47ecf88b685af1e9ea753a574464d6f6fcaa] # ======================================================================== --- commands.cc 177acfa9bb2a5e8a8eca4b8dd87b7e0feef7ff5b +++ commands.cc 22f3729ba21c7f3278e5941b1b589da4b9e9910c @@ -2260,32 +2260,6 @@ } } -static boost::posix_time::ptime -string_to_datetime(std::string const & s) -{ - 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); - } - catch (std::out_of_range &e) - { - N(false, F("failed to parse date string '%s': %s") % s % e.what()); - } - catch (std::exception &) - { - N(false, F("failed to parse date string '%s'") % s); - } - I(false); -} - CMD(commit, N_("working copy"), N_("[PATH]..."), N_("commit working copy to database"), OPT_BRANCH_NAME % OPT_MESSAGE % OPT_MSGFILE % OPT_DATE % OPT_AUTHOR % OPT_DEPTH) ======================================================================== --- git_export.cc f2ea7c4e976be2e6ee857643ae941936d597ab53 +++ git_export.cc 6dca3d75647ad2085c497fe99f245c2c0252f75e @@ -427,7 +427,7 @@ boost::posix_time::ptime atime; string atimestr; load_cert(app, rid, date_name, atimestr); - atime = boost::posix_time::from_iso_string(atimestr); + atime = string_to_datetime(atimestr); git_person committer; string commitline; ======================================================================== --- transforms.cc 05437d611e11ac3f6a0cbef9eb352a112c60d401 +++ transforms.cc a5d73bf198e5007709b22a4b69d09c9cb574cefb @@ -14,6 +14,7 @@ #include #include +#include #include "botan/botan.h" #include "botan/gzip.h" @@ -820,6 +821,33 @@ } +boost::posix_time::ptime +string_to_datetime(std::string const & s) +{ + 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); + } + catch (std::out_of_range &e) + { + N(false, F("failed to parse date string '%s': %s") % s % e.what()); + } + catch (std::exception &) + { + N(false, F("failed to parse date string '%s'") % s); + } + I(false); +} + + #ifdef BUILD_UNIT_TESTS #include "unit_tests.hh" #include ======================================================================== --- transforms.hh 934c5f0c68d4ee8c18a2237398d43a59107e067a +++ transforms.hh 09dd47ecf88b685af1e9ea753a574464d6f6fcaa @@ -13,6 +13,8 @@ #include +#include + // this file contans various sorts of string transformations. each // transformation should be self-explanatory from its type signature. see // transforms.cc for the implementations (most of which are delegations to @@ -198,4 +200,6 @@ // line-ending conversion void line_end_convert(std::string const & linesep, std::string const & src, std::string & dst); +boost::posix_time::ptime string_to_datetime(std::string const & s); + #endif // __TRANSFORMS_HH__