add parser to 1D format
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "cleanHtml.h"
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -53,7 +54,7 @@ int Deals::HelpDealNegative() const
|
||||
PrintFile(DEAL_NEGATIVE_EN);
|
||||
return 0;
|
||||
}
|
||||
Deals::Deals(const InputParser &parser, const bool isRussian, const string address, bool isDebug)
|
||||
Deals::Deals(const InputParser& parser, const bool isRussian, const string address, bool isDebug)
|
||||
{
|
||||
this->parser = parser;
|
||||
this->isRussian = isRussian;
|
||||
@@ -131,6 +132,7 @@ int Deals::Create()
|
||||
}
|
||||
else
|
||||
{
|
||||
pay = GetDate(pay);
|
||||
string untl(",\"until\": \"");
|
||||
untl.append(pay);
|
||||
untl.append("\"");
|
||||
@@ -144,7 +146,7 @@ int Deals::Create()
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
leave_before = GetDate(leave_before);
|
||||
string untl(",\"feedback\": {\"leave-before\": \"");
|
||||
untl.append(leave_before);
|
||||
untl.append("\"}");
|
||||
@@ -168,6 +170,49 @@ int Deals::Create()
|
||||
|
||||
return 0;
|
||||
}
|
||||
string Deals::GetDate(const string date) {
|
||||
string buffer = date;
|
||||
/*
|
||||
-p|--pay { <yyyy-mm-dd> [hh:mm:ss UTC] | <time>[smhd] }
|
||||
Time for make payment; default: 1d
|
||||
*/
|
||||
std::transform(buffer.begin(), buffer.end(), buffer.begin(), ::toupper);
|
||||
if (buffer.length() < 23) {
|
||||
char letter = buffer[buffer.length() - 1];
|
||||
int append = 0;
|
||||
string numval = buffer.substr(0, buffer.length() - 1);
|
||||
int num = stoi(numval);
|
||||
switch (letter)
|
||||
{
|
||||
case 'S':
|
||||
append = num;
|
||||
break;
|
||||
case 'M':
|
||||
append = num * 60;
|
||||
break;
|
||||
case 'H':
|
||||
append = num * 60 * 60;
|
||||
break;
|
||||
case 'D':
|
||||
append = num * 24 * 60 * 60;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
std::time_t utcTimeInSeconds = std::time(nullptr);
|
||||
utcTimeInSeconds += append;
|
||||
|
||||
|
||||
tm * tmm = gmtime(&utcTimeInSeconds);
|
||||
char buff[70];
|
||||
strftime(buff, sizeof buff, "%Y-%m-%d %H:%M:%S UTC", tmm);
|
||||
string result = buff;
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
int Deals::Status()
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ private:
|
||||
int Negative();
|
||||
|
||||
std::string GetVal(const std::string first,const std::string second);
|
||||
|
||||
std::string GetDate(const std::string date);
|
||||
|
||||
};
|
||||
#endif
|
||||
BIN
dm-cli/dm-cli
BIN
dm-cli/dm-cli
Binary file not shown.
@@ -1 +1,3 @@
|
||||
dm-cli deal create -a https://test.com -s mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp -c mraXx7JrmAmuKypdJ1vseQBXySsdRZE5AC -t Prepayment -s 0.1 -l 14d -p 1d
|
||||
dm-cli deal create -a https://test.com -s mnumHs9HQMrw2Q1iKLNnx9NzExS7nMLmyp -c mraXx7JrmAmuKypdJ1vseQBXySsdRZE5AC -t Prepayment -s 0.1 -l 14d -p 1d
|
||||
|
||||
dm-cli --address https://testnet-dm2.bitdeals.org deal status 3e251d8fdcfa80adf5a3050064fc4ecb01d304d1
|
||||
Reference in New Issue
Block a user