// #pragma once #ifndef TARIFF_UTILS_H_INCLUDED #define TARIFF_UTILS_H_INCLUDED #include "tariff_day_of_week.h" #include "tariff_cfg.h" #include "tariff_time_range.h" #include "active_time_range.h" #include #include #include #include #include #include #include /// /// Definition of TariffUtilities class /// class TariffUtils { public: /// /// Validate parking ticket /// /// /// /// /// /// /// static bool ValidateParkingTicket(TariffConfiguration const *tariff_cfg, time_t initial, int durationMin, double price, TariffTimeRange time_range, bool isSpecialDay, int spec_day_id); /// /// Check if time is in range between start and end of active payment hours /// /// Tariff configuration /// Current datetime string /// Special day flag /// Special day ID /// Returns if parking time range is active static ActiveTimeRange isParkingTimeRangeActive(TariffConfiguration *tariff_cfg, std::string datetimeStr, bool isSpecialDay, int spec_day_id); /// /// Get day of week from current date (Zeller's Algorithm), /// starting day is Sunday /// /// /// static DayOfWeek GetDayOfWeek(struct tm const *t); /// /// Identifies special day (e.g. Christmas) /// /// Pointer to tariff configuration data /// Date to be validated /// Reference to special day ID /// Returns if the date is a special day static bool IsSpecialDay(TariffConfiguration const *tariff_cfg, const char *dateTimeStr, int& specialDayId); static bool PriceForSpecialDay(TariffConfiguration const* tariff_cfg, int specialDayId, double *price); /// /// Date and time parse helper function /// /// Returns time (tm) structure static bool DateTimeToStructTm(const char* dateTimeStr, struct tm *t); /// /// Date parse helper function /// /// Returns time (tm) structure static bool DateToStructTm(char const* dateStr, struct tm *t); /// /// Time parse helper function /// /// Returns time (tm) structure static bool TimeToStructTm(const char* timeStr, struct tm *t); /// /// Get current local time /// /// Returns time_t structure static time_t GetCurrentLocalTime(); }; #endif // TARIFF_UTILS_H_INCLUDED