1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#pragma once
#include "common.h"
class AFX_CLASS_EXPORT T2DateTime {
public:
T2DateTime();
T2DateTime(int year, int month, int hours, int minutes, int seconds);
T2DateTime(T2Archive& archive);
T2DateTime(const T2DateTime &other)
: mYear(other.mYear)
, mMonth(other.mMonth)
, mRawMinutes(other.mRawMinutes)
, mSeconds(other.mSeconds)
{}
virtual ~T2DateTime();
virtual void Write(T2Archive& archive);
int GetTimeZone();
void AddMinutes(unsigned int m);
BOOL IsIncDateTime();
void IncDate();
unsigned int CalcLapseDays(unsigned int d) const;
unsigned int CalcLapseYears(unsigned int d) const;
BOOL WithinHour(int a, int b) const;
BOOL WithinMinutes(int a, int b) const;
BOOL IsHoliday(T2TowerDoc* doc);
void Validate();
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; }
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; }
BOOL IsWeekday(T2TowerDoc* doc) { return !IsHoliday(doc); }
BOOL IsDay() const {
return (mRawMinutes >= 360 && mRawMinutes < 1080);
}
BOOL IsMidNight() const {
return mRawMinutes < 360;
}
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;
}
};
inline BOOL operator<=(const T2DateTime &a, const T2DateTime &b) {
return a.CalcTotalCount() <= b.CalcTotalCount();
}
|