Compare commits
No commits in common. "eebb6d926efa3ed4878811fbdc4d4e05d9b21af2" and "5c0bbf15024a42445a1572291e416123922f0c0f" have entirely different histories.
eebb6d926e
...
5c0bbf1502
@ -10,12 +10,7 @@ double total_cost = 0.0f;
|
|||||||
bool overtime = false;
|
bool overtime = false;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
std::string Calculator::GetDurationFromCost(Configuration* cfg, uint8_t payment_option, char const* start_datetime, double price, bool nextDay, bool prepaid)
|
||||||
uint8_t payment_option,
|
|
||||||
char const* start_datetime, // given in local time
|
|
||||||
double price,
|
|
||||||
bool nextDay,
|
|
||||||
bool prepaid)
|
|
||||||
{
|
{
|
||||||
// Get current date time from input
|
// Get current date time from input
|
||||||
struct tm current_datetime = Utilities::DateTimeToStructTm(start_datetime);
|
struct tm current_datetime = Utilities::DateTimeToStructTm(start_datetime);
|
||||||
@ -271,29 +266,15 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg,
|
|||||||
cout << "Total minutes: " << (int)ret_val << endl;
|
cout << "Total minutes: " << (int)ret_val << endl;
|
||||||
if (ret_val <= 0) return "PARKING NOT ALLOWED";
|
if (ret_val <= 0) return "PARKING NOT ALLOWED";
|
||||||
|
|
||||||
#if !defined(_SVID_SOURCE) && !defined(_XOPEN_SOURCE)
|
struct tm valid_until_datetime = *localtime(&valid_until_datetime_t);
|
||||||
// needed for timezone-correction
|
// TEST: no daylight saving time
|
||||||
#error "!defined(_SVID_SOURCE) && !defined(_XOPEN_SOURCE)"
|
// valid_until_datetime.tm_isdst = 0;
|
||||||
#else
|
|
||||||
// timezone correction: localtime() needs argument in UTC-timezone
|
|
||||||
// The global variable 'timezone' is set by tzset(), see
|
|
||||||
// https://linux.die.net/man/3/tzset, so I change of the timezone will
|
|
||||||
// also change the value of the variable 'timezone'.
|
|
||||||
valid_until_datetime_t += timezone;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct tm valid_until_datetime;
|
|
||||||
memset(&valid_until_datetime, 0x00, sizeof(valid_until_datetime));
|
|
||||||
|
|
||||||
if (!localtime_r(&valid_until_datetime_t, &valid_until_datetime)) {
|
|
||||||
return "LOCALTIME_R() ERROR";
|
|
||||||
}
|
|
||||||
|
|
||||||
// return in ISO-format: "%Y-%m-%dT%H:%M:%S"
|
|
||||||
char buf[128];
|
char buf[128];
|
||||||
memset(buf, 0x00, sizeof(buf));
|
memset(buf, 0x00, sizeof(buf));
|
||||||
strftime(buf, sizeof(buf)-1, "%Y-%m-%dT%H:%M:%S", &valid_until_datetime);
|
strftime(buf, sizeof(buf)-1, "%Y-%m-%dT%H:%M:%S", &valid_until_datetime);
|
||||||
|
|
||||||
|
// LOG_DEBUG("Ticket is valid until ", asctime(&valid_until_datetime));
|
||||||
LOG_DEBUG("Ticket is valid until ", buf);
|
LOG_DEBUG("Ticket is valid until ", buf);
|
||||||
|
|
||||||
total_duration_min = 0.0f;
|
total_duration_min = 0.0f;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user