From 73eeb7321fbd1029fb2ec52877c8d1fc73945cd4 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 24 Nov 2016 07:11:18 +0800 Subject: [PATCH] dateparser class removed --- ext/CMakeLists.txt | 3 +-- ext/dateparser.cpp | 35 ----------------------------------- ext/dateparser.h | 27 --------------------------- src/tools.cpp | 30 ------------------------------ src/tools.h | 5 ----- 5 files changed, 1 insertion(+), 99 deletions(-) delete mode 100644 ext/dateparser.cpp delete mode 100644 ext/dateparser.h diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index b526fa2..13be6f0 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -8,11 +8,10 @@ project(myext) set(SOURCE_HEADERS minicsv.h format.h - dateparser.h) + ) set(SOURCE_FILES format.cc - dateparser.cpp date/tz.cpp) # make static library called libmyxrm diff --git a/ext/dateparser.cpp b/ext/dateparser.cpp deleted file mode 100644 index 0fd83fa..0000000 --- a/ext/dateparser.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// -// Created by marcin on 22/11/15. -// - -#include "dateparser.h" - - -dateparser::dateparser(std::string fmt) -{ - // set format - using namespace boost::local_time; - local_time_input_facet* input_facet = new local_time_input_facet(); - input_facet->format(fmt.c_str()); - ss.imbue(std::locale(ss.getloc(), input_facet)); -} - - -bool -dateparser::operator()(std::string const& text) -{ - ss.clear(); - ss.str(text); - - bool ok = bool(ss >> pt); - - if (ok) - { - auto tm = to_tm(pt); - year = tm.tm_year; - month = tm.tm_mon + 1; // for 1-based (1:jan, .. 12:dec) - day = tm.tm_mday; - } - - return ok; -} \ No newline at end of file diff --git a/ext/dateparser.h b/ext/dateparser.h deleted file mode 100644 index 4216a48..0000000 --- a/ext/dateparser.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// Created by marcin on 22/11/15. -// - -#ifndef XMR2CSV_DATEPARSER_H -#define XMR2CSV_DATEPARSER_H - -#include -#include - - -// taken from: http://stackoverflow.com/a/19482908/248823 -struct dateparser -{ - boost::posix_time::ptime pt; - unsigned year, month, day; - - dateparser(std::string fmt); - - bool - operator()(std::string const& text); - -private: - std::stringstream ss; -}; - -#endif //XMR2CSV_DATEPARSER_H diff --git a/src/tools.cpp b/src/tools.cpp index d4fea25..d5b8b7b 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -507,36 +507,6 @@ namespace xmreg } - /** - * Rough estimate of block height from the time provided - * - */ - uint64_t - estimate_bc_height(const string& date, const char* format) - { - const pt::ptime MONERO_START {gt::date(2014,04,18)}; - const uint64_t MONERO_BLOCK_TIME {60}; // seconds - - dateparser parser {format}; - - if (!parser(date)) - { - throw runtime_error(string("Date format is incorrect: ") + date); - } - - pt::ptime requested_date = parser.pt; - - if (requested_date < MONERO_START) - { - return 0; - } - - pt::time_duration td = requested_date - MONERO_START; - - return static_cast(td.total_seconds()) / MONERO_BLOCK_TIME; - } - - array timestamp_difference(uint64_t t1, uint64_t t2) { diff --git a/src/tools.h b/src/tools.h index 231ca4a..333fd66 100644 --- a/src/tools.h +++ b/src/tools.h @@ -16,7 +16,6 @@ #include "monero_headers.h" #include "tx_details.h" -#include "../ext/dateparser.h" #include "../ext/infix_iterator.h" #include "../ext/date/tz.h" @@ -171,10 +170,6 @@ enable_monero_log() { } -uint64_t -estimate_bc_height(const string& date, const char* format = "%Y-%m-%d"); - - inline double get_xmr(uint64_t core_amount) {