diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-06-28 22:22:32 +0100 |
commit | c0c336500955a23e344651e5412c9d9d441ef4ee (patch) | |
tree | 790769c748db307cf3314f6e896e2f61c68561a2 /src/T2DLL/T2DateTime.h | |
parent | 37e364b2c6cc7487a1c888d256a73e5337bb7189 (diff) | |
download | t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.tar.gz t2win-c0c336500955a23e344651e5412c9d9d441ef4ee.zip |
first pass of T2DLL
Diffstat (limited to '')
-rw-r--r-- | src/T2DLL/T2DateTime.h | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/src/T2DLL/T2DateTime.h b/src/T2DLL/T2DateTime.h index 288ef9b..faf02fe 100644 --- a/src/T2DLL/T2DateTime.h +++ b/src/T2DLL/T2DateTime.h @@ -1,30 +1,28 @@ #pragma once #include "common.h" -class T2DateTime { +class AFX_EXT_CLASS T2DateTime { public: T2DateTime(); T2DateTime(int year, int month, int hours, int minutes, int seconds); T2DateTime(T2Archive& archive); virtual ~T2DateTime(); + virtual void Write(T2Archive& archive); + int GetTimeZone(); - static int IsEqualDate(T2DateTime* a, T2DateTime* b); - static int IsEqualDateTime(T2DateTime* a, T2DateTime* b); void AddMinutes(unsigned int m); - int IsIncDateTime(); + BOOL 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); + BOOL WithinHour(int a, int b) const; + BOOL WithinMinutes(int a, int b) const; + BOOL IsHoliday(T2TowerDoc* doc); void Validate(); - //T2DateTime(const T2DateTime&) {} + static BOOL IsEqualDate(T2DateTime* a, T2DateTime* b); + static BOOL IsEqualDateTime(T2DateTime* a, T2DateTime* b); + unsigned int GetYear() const { return mYear; } unsigned int GetQuarter() const { return mMonth / 3 + 1; } unsigned int GetSeason() const { return mMonth / 3 + 1; } @@ -35,25 +33,32 @@ public: 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); + BOOL IsWeekday(T2TowerDoc* doc) { return !IsHoliday(doc); } + BOOL IsDay() const { + return (mRawMinutes >= 360 && mRawMinutes < 1080); } - int IsMidNight() const { + BOOL IsMidNight() const { return mRawMinutes < 360; } - int IsOclock24(unsigned int hour) const { + BOOL IsOclock24(unsigned int hour) const { return (Get24Hour() == hour) && (GetMinutes() == 0) && (mSeconds == 0); } + + unsigned int mYear; + unsigned int mMonth; + unsigned int mRawMinutes; + unsigned int mSeconds; + protected: + int AdjustMinutes(int m) const; + + friend BOOL operator>=(const T2DateTime &a, const T2DateTime &b); + 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; }; + +inline BOOL operator>=(const T2DateTime &a, const T2DateTime &b) { + return a.CalcTotalCount() >= b.CalcTotalCount(); +} |