add parser to 1D format

This commit is contained in:
Vladimir N. Korotenko
2025-11-15 12:30:25 +03:00
parent d49d8cac18
commit 2ace6d33e2
7 changed files with 2122 additions and 4 deletions

2065
dm-cli.v3.html Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -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()
{

View File

@@ -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

Binary file not shown.

View File

@@ -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

View File

@@ -45,9 +45,12 @@
<ClCompile Include="..\dm-cli\ShowDebug.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="..\dm-cli\check.sh" />
<None Include="..\dm-cli\createdistr.sh" />
<None Include="..\dm-cli\Makefile">
<DeploymentContent>true</DeploymentContent>
</None>
<None Include="..\dm-cli\test.cmd" />
</ItemGroup>
<ItemGroup>
<Text Include="..\dm-cli\account_status_en.txt">

View File

@@ -88,6 +88,9 @@
<None Include="..\dm-cli\Makefile">
<Filter>Resource Files</Filter>
</None>
<None Include="..\dm-cli\test.cmd" />
<None Include="..\dm-cli\createdistr.sh" />
<None Include="..\dm-cli\check.sh" />
</ItemGroup>
<ItemGroup>
<Text Include="..\dm-cli\main_help_ru.txt">