Merge branch 'master' of git.mimbach49.de:GerhardHoffmann/MOBILISIS-Calculator
This commit is contained in:
		@@ -10,7 +10,12 @@ double total_cost = 0.0f;
 | 
			
		||||
bool overtime = false;
 | 
			
		||||
 | 
			
		||||
/// <inheritdoc/>
 | 
			
		||||
std::string Calculator::GetDurationFromCost(Configuration* cfg, uint8_t payment_option, char const* start_datetime, double price, bool nextDay, bool prepaid)
 | 
			
		||||
std::string Calculator::GetDurationFromCost(Configuration* cfg,
 | 
			
		||||
                                            uint8_t payment_option,
 | 
			
		||||
                                            char const* start_datetime, // given in local time
 | 
			
		||||
                                            double price,
 | 
			
		||||
                                            bool nextDay,
 | 
			
		||||
                                            bool prepaid)
 | 
			
		||||
{
 | 
			
		||||
	// Get current date time from input
 | 
			
		||||
	struct tm current_datetime = Utilities::DateTimeToStructTm(start_datetime);
 | 
			
		||||
@@ -264,17 +269,31 @@ std::string Calculator::GetDurationFromCost(Configuration* cfg, uint8_t payment_
 | 
			
		||||
	else ret_val = total_duration_min;
 | 
			
		||||
 | 
			
		||||
	cout << "Total minutes: " << (int)ret_val << endl;
 | 
			
		||||
	if (ret_val <= 0) return "PARKING NOT ALLOWED";
 | 
			
		||||
    if (ret_val <= 0) return "PARKING NOT ALLOWED";
 | 
			
		||||
 | 
			
		||||
    struct tm valid_until_datetime = *localtime(&valid_until_datetime_t);
 | 
			
		||||
    // TEST: no daylight saving time
 | 
			
		||||
    // valid_until_datetime.tm_isdst = 0;
 | 
			
		||||
#if !defined(_SVID_SOURCE) && !defined(_XOPEN_SOURCE)
 | 
			
		||||
    // needed for timezone-correction
 | 
			
		||||
    #error "!defined(_SVID_SOURCE) && !defined(_XOPEN_SOURCE)"
 | 
			
		||||
#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];
 | 
			
		||||
    memset(buf, 0x00, sizeof(buf));
 | 
			
		||||
    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);
 | 
			
		||||
 | 
			
		||||
	total_duration_min = 0.0f;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user