diff --git a/src/page.h b/src/page.h index 15d5c2d..a017699 100644 --- a/src/page.h +++ b/src/page.h @@ -2248,21 +2248,22 @@ namespace xmreg { // such search start with "aoi_", e.g., "aoi_444-23.00" bool search_for_amount_output_idx = (search_text.substr(0, 4) == "aoi_"); - // check if date given in format: 2005-04-55 // this is 10 characters - if (search_text.length() == 10) + if (search_text.length() == 19) { uint64_t estimated_blk_height {0}; // first parse the string date into boost's ptime object - dateparser parser {"%Y-%m-%d"}; + dateparser parser {"%Y-%m-%d %H:%M:%S"}; if (parser(search_text)) { // seems we have a correct date! // so try to estimate block height from it. + cout << "timestamp: " << xmreg::ptime_to_time_t(parser.pt) << endl; + // estimate blockchain height from the start date provided estimated_blk_height = xmreg::estimate_bc_height(search_text); diff --git a/src/tools.cpp b/src/tools.cpp index f11f911..c2a6b73 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -629,6 +629,13 @@ namespace xmreg return make_pair(empty_time, scale); } + time_t + ptime_to_time_t(const pt::ptime& in_ptime) + { + static pt::ptime epoch(gt::date(1970, 1, 1)); + pt::time_duration::sec_type no_seconds = (in_ptime - epoch).total_seconds(); + return time_t(no_seconds); + } bool decode_ringct(const rct::rctSig& rv, diff --git a/src/tools.h b/src/tools.h index 1de0b8a..813a477 100644 --- a/src/tools.h +++ b/src/tools.h @@ -220,6 +220,9 @@ namespace xmreg uint64_t time0 = 1397818193 /* timestamp of the second block */); + time_t + ptime_to_time_t(const pt::ptime& in_ptime); + bool decode_ringct(const rct::rctSig & rv, const crypto::public_key pub,