checkin for the weekend. proper commit-messages later
This commit is contained in:
@@ -118,10 +118,10 @@ int main() {
|
||||
QDateTime s(QDate(2023, 11, 30), QTime());
|
||||
// QDateTime s(QDate(2023, 11, 26), QTime());
|
||||
QDateTime end;
|
||||
for (int duration = 30; duration <= 30; duration += 5) {
|
||||
for (int duration = 35; duration <= 35; duration += 5) {
|
||||
// for (int duration = 30; duration <= maxParkingTime; duration += 5) {
|
||||
qCritical() << "";
|
||||
for (int offset = 721; offset <= 721; ++offset) {
|
||||
for (int offset = 1046; offset <= 1046; ++offset) {
|
||||
//for (int offset = 420; offset <= 1080; ++offset) {
|
||||
//if (offset > 720 && offset < 840) {
|
||||
// continue;
|
||||
@@ -130,8 +130,9 @@ int main() {
|
||||
QDateTime const firstStart = start;
|
||||
// qCritical() << "start" << start.toString(Qt::ISODate);
|
||||
|
||||
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 3, start, end, duration, nextDay, prePaid);
|
||||
double cost = Calculator::GetInstance().GetCostFromDuration(&cfg, 1, start, end, duration, nextDay, prePaid);
|
||||
|
||||
#if COST_FROM_DURATION==1
|
||||
double cost_soll = 30 + ((duration-30)/5 * 10);
|
||||
uint32_t duration_ist = start.secsTo(end) / 60;
|
||||
|
||||
@@ -160,13 +161,16 @@ int main() {
|
||||
//break;
|
||||
}
|
||||
|
||||
#else
|
||||
std::string duration = Calculator::GetInstance().GetDurationFromCost(&cfg, 1,
|
||||
start.toString(Qt::ISODate).toStdString().c_str(),
|
||||
cost, false, true);
|
||||
qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
<< "cost" << cost
|
||||
<< "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
|
||||
|
||||
#endif // COST_FROM_DURATION
|
||||
|
||||
|
||||
//std::string duration = calculator.GetDurationFromCost(&cfg, 3, start.toString(Qt::ISODate).toStdString().c_str(), cost);
|
||||
//qCritical() << "start" << start.toString(Qt::ISODate)
|
||||
// << "cost" << cost
|
||||
// << "until" << duration.c_str() << start.secsTo(QDateTime::fromString(duration.c_str(), Qt::ISODate)) / 60;
|
||||
}
|
||||
}
|
||||
#endif // 0
|
||||
|
75
main/main.cpp.bck.23112023
Normal file
75
main/main.cpp.bck.23112023
Normal file
@@ -0,0 +1,75 @@
|
||||
#ifdef WIN32
|
||||
#include <time.h>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
extern "C" char* strptime(const char* s,
|
||||
const char* f,
|
||||
struct tm* tm) {
|
||||
// Isn't the C++ standard lib nice? std::get_time is defined such that its
|
||||
// format parameters are the exact same as strptime. Of course, we have to
|
||||
// create a string stream first, and imbue it with the current C locale, and
|
||||
// we also have to make sure we return the right things if it fails, or
|
||||
// if it succeeds, but this is still far simpler an implementation than any
|
||||
// of the versions in any of the C standard libraries.
|
||||
std::istringstream input(s);
|
||||
input.imbue(std::locale(setlocale(LC_ALL, nullptr)));
|
||||
input >> std::get_time(tm, f);
|
||||
if (input.fail()) {
|
||||
return nullptr;
|
||||
}
|
||||
return (char*)(s + input.tellg());
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "calculate_price.h"
|
||||
#include "calculator_functions.h"
|
||||
#include "payment_method.h"
|
||||
#include "payment_option.h"
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
static Calculator calculator;
|
||||
int main() {
|
||||
|
||||
parking_tariff_t *tariff = 0;
|
||||
if (init_tariff(&tariff, "/tmp"))
|
||||
{
|
||||
|
||||
|
||||
for(auto itr = tariff->WeekDaysWorktime.begin(); itr != tariff->WeekDaysWorktime.end(); ++itr)
|
||||
{
|
||||
qCritical() << itr->first << "TO " << itr->second.pwd_time_from.c_str();
|
||||
qCritical() << itr->first << "FROM" << itr->second.pwd_time_from.c_str();
|
||||
}
|
||||
|
||||
for (auto[itr, rangeEnd] = tariff->WeekDaysWorktime.equal_range(36); itr != rangeEnd; ++itr)
|
||||
{
|
||||
qCritical() << itr->first << itr->second.pwd_time_from.c_str();
|
||||
}
|
||||
|
||||
#if 0
|
||||
struct price_t price;
|
||||
memset(&price, 0x00, sizeof(price));
|
||||
QDateTime start = QDateTime::fromString("2023-11-22T14:00:00.000Z",Qt::ISODate); //QDateTime::currentDateTime();
|
||||
//QDateTime start = QDateTime::currentDateTime();
|
||||
for (int j=30; j <=180; j+=5) {
|
||||
QDateTime s = start.addSecs(j*60);
|
||||
for (int i = 60; i <= 360; i+=10) {
|
||||
std::string a = calculator.GetDurationFromCost(tariff, PaymentOption::Option1,
|
||||
s.toString(Qt::ISODate).toStdString().c_str(),
|
||||
i);
|
||||
|
||||
//qCritical() << "cost=" << i << ", duration=" << QString(a.c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
free_tariff(tariff);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user