summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-08-10 13:00:53 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-08-10 13:00:53 +0300
commitfd759b7af2ad824149b8ef7459a5865490cee192 (patch)
tree40647e4b1cf8274d08d1cd6b30df20cd3efd7f03
parente7d6c4e5d1081049511e07c91f57e0263b8a25c5 (diff)
Import: support for date/time in human-readable format (yyyy-mm-dd hh:mm:ss)
{ "history": [ { "eventType":0, "time":"2014-12-31 12:12:12", "flags":"m", "body":"boooo" }, { "eventType":0, "timeStamp":98235, "flags":"r", "body":"moooo" } ] }
-rw-r--r--plugins/Import/src/textjson.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/plugins/Import/src/textjson.cpp b/plugins/Import/src/textjson.cpp
index d964d56e81..1267148550 100644
--- a/plugins/Import/src/textjson.cpp
+++ b/plugins/Import/src/textjson.cpp
@@ -95,7 +95,25 @@ public:
return 0;
dbei->eventType = (*node)["eventType"].as_int();
- dbei->timestamp = (*node)["timeStamp"].as_int();
+
+ dbei->timestamp = 0;
+ std::string szTime = (*node)["time"].as_string();
+ if (!szTime.empty()) {
+ char c;
+ struct tm st = {};
+ int res = sscanf(szTime.c_str(), "%4d%c%2d%c%2d %2d:%2d:%2d", &st.tm_year, &c, &st.tm_mon, &c, &st.tm_mday, &st.tm_hour, &st.tm_min, &st.tm_sec);
+ if (res == 8) {
+ st.tm_mon--;
+ st.tm_mday--;
+ st.tm_year -= 1900;
+ time_t tm = mktime(&st);
+ if (tm != -1)
+ dbei->timestamp = tm;
+ }
+ }
+
+ if (dbei->timestamp == 0)
+ dbei->timestamp = (*node)["timeStamp"].as_int();
dbei->flags = 0;
std::string szFlags = (*node)["flags"].as_string();