summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2DateTime.h
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-06-14 00:50:34 +0100
committerAsh Wolf <ninji@wuffs.org>2023-06-14 00:50:34 +0100
commit37e364b2c6cc7487a1c888d256a73e5337bb7189 (patch)
treeeaf6e857382eef16c2dd940eb4125536fbe068bd /src/T2DLL/T2DateTime.h
downloadt2win-37e364b2c6cc7487a1c888d256a73e5337bb7189.tar.gz
t2win-37e364b2c6cc7487a1c888d256a73e5337bb7189.zip
initial commit
Diffstat (limited to '')
-rw-r--r--src/T2DLL/T2DateTime.h59
1 files changed, 59 insertions, 0 deletions
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;
+};