2323#include < tuple>
2424
2525#include < boost/algorithm/string.hpp>
26- #include < boost/date_time/posix_time/posix_time.hpp>
2726
2827#include < univalue.h>
2928
3029
31- int64_t static DecodeDumpTime (const std::string &str) {
32- static const boost::posix_time::ptime epoch = boost::posix_time::from_time_t (0 );
33- static const std::locale loc (std::locale::classic (),
34- new boost::posix_time::time_input_facet (" %Y-%m-%dT%H:%M:%SZ" ));
35- std::istringstream iss (str);
36- iss.imbue (loc);
37- boost::posix_time::ptime ptime (boost::date_time::not_a_date_time);
38- iss >> ptime;
39- if (ptime.is_not_a_date_time ())
40- return 0 ;
41- return (ptime - epoch).total_seconds ();
42- }
4330
4431std::string static EncodeDumpString (const std::string &str) {
4532 std::stringstream ret;
@@ -598,7 +585,7 @@ UniValue importwallet(const JSONRPCRequest& request)
598585 continue ;
599586 CKey key = DecodeSecret (vstr[0 ]);
600587 if (key.IsValid ()) {
601- int64_t nTime = DecodeDumpTime (vstr[1 ]);
588+ int64_t nTime = ParseISO8601DateTime (vstr[1 ]);
602589 std::string strLabel;
603590 bool fLabel = true ;
604591 for (unsigned int nStr = 2 ; nStr < vstr.size (); nStr++) {
@@ -617,7 +604,7 @@ UniValue importwallet(const JSONRPCRequest& request)
617604 } else if (IsHex (vstr[0 ])) {
618605 std::vector<unsigned char > vData (ParseHex (vstr[0 ]));
619606 CScript script = CScript (vData.begin (), vData.end ());
620- int64_t birth_time = DecodeDumpTime (vstr[1 ]);
607+ int64_t birth_time = ParseISO8601DateTime (vstr[1 ]);
621608 scripts.push_back (std::pair<CScript, int64_t >(script, birth_time));
622609 }
623610 }
0 commit comments