add parser to 1D format
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include "cleanHtml.h"
|
#include "cleanHtml.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -53,7 +54,7 @@ int Deals::HelpDealNegative() const
|
|||||||
PrintFile(DEAL_NEGATIVE_EN);
|
PrintFile(DEAL_NEGATIVE_EN);
|
||||||
return 0;
|
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->parser = parser;
|
||||||
this->isRussian = isRussian;
|
this->isRussian = isRussian;
|
||||||
@@ -131,6 +132,7 @@ int Deals::Create()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
pay = GetDate(pay);
|
||||||
string untl(",\"until\": \"");
|
string untl(",\"until\": \"");
|
||||||
untl.append(pay);
|
untl.append(pay);
|
||||||
untl.append("\"");
|
untl.append("\"");
|
||||||
@@ -144,7 +146,7 @@ int Deals::Create()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
leave_before = GetDate(leave_before);
|
||||||
string untl(",\"feedback\": {\"leave-before\": \"");
|
string untl(",\"feedback\": {\"leave-before\": \"");
|
||||||
untl.append(leave_before);
|
untl.append(leave_before);
|
||||||
untl.append("\"}");
|
untl.append("\"}");
|
||||||
@@ -168,6 +170,49 @@ int Deals::Create()
|
|||||||
|
|
||||||
return 0;
|
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()
|
int Deals::Status()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ private:
|
|||||||
int Negative();
|
int Negative();
|
||||||
|
|
||||||
std::string GetVal(const std::string first,const std::string second);
|
std::string GetVal(const std::string first,const std::string second);
|
||||||
|
std::string GetDate(const std::string date);
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#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
|
||||||
@@ -45,9 +45,12 @@
|
|||||||
<ClCompile Include="..\dm-cli\ShowDebug.cpp" />
|
<ClCompile Include="..\dm-cli\ShowDebug.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="..\dm-cli\check.sh" />
|
||||||
|
<None Include="..\dm-cli\createdistr.sh" />
|
||||||
<None Include="..\dm-cli\Makefile">
|
<None Include="..\dm-cli\Makefile">
|
||||||
<DeploymentContent>true</DeploymentContent>
|
<DeploymentContent>true</DeploymentContent>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="..\dm-cli\test.cmd" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="..\dm-cli\account_status_en.txt">
|
<Text Include="..\dm-cli\account_status_en.txt">
|
||||||
|
|||||||
@@ -88,6 +88,9 @@
|
|||||||
<None Include="..\dm-cli\Makefile">
|
<None Include="..\dm-cli\Makefile">
|
||||||
<Filter>Resource Files</Filter>
|
<Filter>Resource Files</Filter>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="..\dm-cli\test.cmd" />
|
||||||
|
<None Include="..\dm-cli\createdistr.sh" />
|
||||||
|
<None Include="..\dm-cli\check.sh" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Text Include="..\dm-cli\main_help_ru.txt">
|
<Text Include="..\dm-cli\main_help_ru.txt">
|
||||||
|
|||||||
Reference in New Issue
Block a user