Added overload for CheckSpecialDay().
Added helpers SpecialDaysWorkTimeFrom() and SpecialDaysWorkTimeUntil().
This commit is contained in:
		| @@ -9,46 +9,46 @@ | ||||
| #include "configuration.h" | ||||
| #include "time_range.h" | ||||
|  | ||||
| #include <QDateTime> | ||||
|  | ||||
| using namespace std; | ||||
|  | ||||
| class Utilities { | ||||
| public: | ||||
|  | ||||
| namespace Utilities { | ||||
| 	/// <summary> | ||||
| 	/// Get day of week from current date (Zeller's Algorithm), starting day is Sunday | ||||
| 	/// </summary> | ||||
| 	/// <param name="date"></param> | ||||
| 	/// <returns></returns> | ||||
| 	static DayOfWeek GetDayOfWeek(struct tm* tm); | ||||
| 	DayOfWeek GetDayOfWeek(struct tm* tm); | ||||
|  | ||||
| 	/// <summary> | ||||
| 	/// Date and time parse helper function | ||||
| 	/// </summary> | ||||
| 	/// <returns>Returns time (tm) structure</returns> | ||||
| 	static struct tm DateTimeToStructTm(const char* dateTimeStr); | ||||
| 	struct tm DateTimeToStructTm(const char* dateTimeStr); | ||||
|  | ||||
| 	/// <summary> | ||||
| 	/// Date parse helper function | ||||
| 	/// </summary> | ||||
| 	/// <returns>Returns time (tm) structure</returns> | ||||
| 	static struct tm DateToStructTm(const char* dateStr); | ||||
| 	struct tm DateToStructTm(const char* dateStr); | ||||
|  | ||||
| 	/// <summary> | ||||
| 	/// Time parse helper function | ||||
| 	/// </summary> | ||||
| 	/// <returns>Returns time (tm) structure</returns> | ||||
| 	static struct tm TimeToStructTm(const char* timeStr, int year, int mon, int mday, int wday); | ||||
| 	struct tm TimeToStructTm(const char* timeStr, int year, int mon, int mday, int wday); | ||||
|  | ||||
| 	/// <summary> | ||||
| 	/// Get current local time | ||||
| 	/// </summary> | ||||
| 	/// <returns>Returns time_t structure</returns> | ||||
| 	static time_t GetCurrentLocalTime(); | ||||
| 	time_t GetCurrentLocalTime(); | ||||
|  | ||||
| 	/// <summary> | ||||
| 	/// Zeller's algorithm for determining day of week | ||||
| 	/// </summary> | ||||
| 	static int ZellersAlgorithm(int day, int month, int year); | ||||
| 	int ZellersAlgorithm(int day, int month, int year); | ||||
|  | ||||
| 	/// <summary> | ||||
| 	///  Checks if current datetime is in range between start and end month of parking worktime | ||||
| @@ -56,18 +56,23 @@ public: | ||||
| 	/// <param name="tariff_cfg"></param> | ||||
| 	/// <param name="currentDateTime"></param> | ||||
| 	/// <returns></returns> | ||||
| 	static bool IsYearPeriodActive(Configuration* cfg, struct tm* currentDateTime); | ||||
| 	bool IsYearPeriodActive(Configuration* cfg, struct tm* currentDateTime); | ||||
|  | ||||
| 	/// <summary> | ||||
| 	/// Check permissions | ||||
| 	/// </summary> | ||||
| 	static bool CheckSpecialDay(Configuration* cfg, const char* currentDateTimeStr, int* specialDayId, double* specialDayPrice); | ||||
| 	bool CheckSpecialDay(Configuration* cfg, const char* currentDateTimeStr, int* specialDayId, double* specialDayPrice); | ||||
| 	bool CheckSpecialDay(Configuration const *cfg, | ||||
| 						 QDateTime const ¤tDateTimeS, | ||||
| 						 int* specialDayId, uint32_t *specialDayPrice); | ||||
|  | ||||
| 	/// <summary> | ||||
| 	/// Calculates price per unit | ||||
| 	/// </summary> | ||||
| 	/// <param name="pra_price"></param> | ||||
| 	/// <returns></returns> | ||||
|     static double CalculatePricePerUnit(double pra_price, double durationUnit = -1); | ||||
| 	double CalculatePricePerUnit(double pra_price, double durationUnit = -1); | ||||
|  | ||||
| }; | ||||
|     QTime SpecialDaysWorkTimeFrom(Configuration const *cfg, int specialDayId); | ||||
|     QTime SpecialDaysWorkTimeUntil(Configuration const *cfg, int specialDayId); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user