From 37e364b2c6cc7487a1c888d256a73e5337bb7189 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 14 Jun 2023 00:50:34 +0100 Subject: initial commit --- src/T2DLL/T2DateTime.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/T2DLL/T2DateTime.h (limited to 'src/T2DLL/T2DateTime.h') diff --git a/src/T2DLL/T2DateTime.h b/src/T2DLL/T2DateTime.h new file mode 100644 index 0000000..288ef9b --- /dev/null +++ b/src/T2DLL/T2DateTime.h @@ -0,0 +1,59 @@ +#pragma once +#include "common.h" + +class T2DateTime { +public: + T2DateTime(); + T2DateTime(int year, int month, int hours, int minutes, int seconds); + T2DateTime(T2Archive& archive); + virtual ~T2DateTime(); + int GetTimeZone(); + static int IsEqualDate(T2DateTime* a, T2DateTime* b); + static int IsEqualDateTime(T2DateTime* a, T2DateTime* b); + void AddMinutes(unsigned int m); + int IsIncDateTime(); + void IncDate(); + unsigned int CalcLapseDays(unsigned int d) const; + unsigned int CalcLapseYears(unsigned int d) const; + int WithinHour(int a, int b) const; + int WithinMinutes(int a, int b) const; +protected: + int AdjustMinutes(int m) const; +public: + virtual void Write(T2Archive& archive); + int IsHoliday(T2TowerDoc* doc); + void Validate(); + + //T2DateTime(const T2DateTime&) {} + unsigned int GetYear() const { return mYear; } + unsigned int GetQuarter() const { return mMonth / 3 + 1; } + unsigned int GetSeason() const { return mMonth / 3 + 1; } + unsigned int GetDay() const { return mMonth % 3 + 1; } + unsigned int GetMonth() const { return mMonth + 1; } + unsigned int GetHour() const { return (mRawMinutes % 720) / 60; } + unsigned int Get24Hour() const { return mRawMinutes / 60; } + unsigned int GetMinutes() const { return mRawMinutes % 60; } + unsigned int GetRawMinutes() const { return mRawMinutes; } + int CalcTotalDays() const { return (mYear - 1) * 12 + mMonth; } + int IsWeekday(T2TowerDoc* doc) { return !IsHoliday(doc); } + int IsDay() const { + return (mRawMinutes >= 360 && mRawMinutes <= 1079); + } + int IsMidNight() const { + return mRawMinutes < 360; + } + int IsOclock24(unsigned int hour) const { + return (Get24Hour() == hour) && (GetMinutes() == 0) && (mSeconds == 0); + } +protected: + unsigned int CalcTotalCount() const { + return mSeconds + ((mYear * 12 + mMonth) * 1440 + mRawMinutes) * 4; + } +//public: + //T2DateTime& operator=(const T2DateTime&) {} + + unsigned int mYear; + unsigned int mMonth; + unsigned int mRawMinutes; + unsigned int mSeconds; +}; -- cgit v1.2.3