11
11
12
12
namespace cppbox {
13
13
14
- bool CDate::operator ==(const CDate& rh) const {
14
+ bool CDate::operator ==(const CDate& rh) const
15
+ {
15
16
if (m_nYear == rh.m_nYear && m_nMon == rh.m_nMon && m_nDay == rh.m_nDay ) {
16
17
return true ;
17
18
}
18
19
return false ;
19
20
}
20
21
21
22
CDate::CDate () = default ;
22
- CDate::CDate (const CDate& date) {
23
+ CDate::CDate (const CDate& date)
24
+ {
23
25
m_nYear = date.m_nYear ;
24
26
m_nMon = date.m_nMon ;
25
27
m_nDay = date.m_nDay ;
26
28
}
27
- CDate::CDate (int y, int m, int d) {
29
+ CDate::CDate (int y, int m, int d)
30
+ {
28
31
m_nYear = y;
29
32
m_nMon = m;
30
33
m_nDay = d;
31
34
}
32
- CDate& CDate::operator =(const CDate& date) {
35
+ CDate& CDate::operator =(const CDate& date)
36
+ {
33
37
if (this == &date) {
34
38
return *this ;
35
39
}
@@ -39,7 +43,8 @@ CDate& CDate::operator=(const CDate& date) {
39
43
return *this ;
40
44
}
41
45
42
- CDateTime::CDateTime (const CDate& rh) {
46
+ CDateTime::CDateTime (const CDate& rh)
47
+ {
43
48
m_date.m_nYear = rh.m_nYear ;
44
49
m_date.m_nMon = rh.m_nMon ;
45
50
m_date.m_nDay = rh.m_nDay ;
@@ -48,7 +53,8 @@ CDateTime::CDateTime(const CDate& rh) {
48
53
m_time.m_nSec = 0 ;
49
54
}
50
55
51
- CDateTime::CDateTime (int y, int m, int d, int h, int min, int sec) {
56
+ CDateTime::CDateTime (int y, int m, int d, int h, int min, int sec)
57
+ {
52
58
m_date.m_nYear = y;
53
59
m_date.m_nMon = m;
54
60
m_date.m_nDay = d;
@@ -57,7 +63,8 @@ CDateTime::CDateTime(int y, int m, int d, int h, int min, int sec) {
57
63
m_time.m_nSec = sec;
58
64
}
59
65
60
- CDateTime& CDateTime::operator =(const CDateTime& datetime) {
66
+ CDateTime& CDateTime::operator =(const CDateTime& datetime)
67
+ {
61
68
if (this == &datetime) {
62
69
return *this ;
63
70
}
@@ -78,28 +85,27 @@ CDateTime& CDateTime::operator=(const CDate& date)
78
85
return *this ;
79
86
}
80
87
81
- CCalenderBase* CCalenderFactory::creatInstance (CalendarType etype) {
88
+ CCalenderBase* CCalenderFactory::creatInstance (CalendarType etype)
89
+ {
82
90
CCalenderBase* pResult = nullptr ;
83
91
84
92
switch (etype) {
85
- case CALENDAR_V1: {
86
- pResult = new CCalenderV1 ();
87
- break ;
88
- }
89
- case CALENDAR_V2: {
90
- pResult = new CCalenderV2 ();
91
- break ;
92
- }
93
- default :
94
- break ;
93
+ case CALENDAR_V1: {
94
+ pResult = new CCalenderV1 ();
95
+ break ;
96
+ }
97
+ case CALENDAR_V2: {
98
+ pResult = new CCalenderV2 ();
99
+ break ;
100
+ }
101
+ default :
102
+ break ;
95
103
}
96
104
return pResult;
97
105
}
98
106
99
107
// 释放内存
100
- void CCalenderFactory::freeCalender (CCalenderBase* pCalender) {
101
- delete pCalender;
102
- }
108
+ void CCalenderFactory::freeCalender (CCalenderBase* pCalender) { delete pCalender; }
103
109
104
110
CCalenderBase::CCalenderBase () = default ;
105
111
@@ -108,7 +114,8 @@ CDateTime const& CCalenderBase::getDateTime() const { return m_datetime; }
108
114
CDateTime const & CCalenderBase::getLunarDateTime () const { return m_ldatetime; }
109
115
#ifdef _WIN32
110
116
// 获取系统时间
111
- void CCalenderBase::getNowDateTime (CDateTime& datetime) {
117
+ void CCalenderBase::getNowDateTime (CDateTime& datetime)
118
+ {
112
119
SYSTEMTIME nowTime;
113
120
GetLocalTime (&nowTime);
114
121
datetime.m_date .m_nYear = nowTime.wYear ;
@@ -120,7 +127,8 @@ void CCalenderBase::getNowDateTime(CDateTime& datetime) {
120
127
}
121
128
#else
122
129
// 获取系统时间
123
- void CCalenderBase::getNowDateTime (CDateTime& datetime) {
130
+ void CCalenderBase::getNowDateTime (CDateTime& datetime)
131
+ {
124
132
struct std ::tm * nowTime = nullptr ;
125
133
std::time_t _otime_t ;
126
134
std::time (&_otime_t );
@@ -201,7 +209,8 @@ bool CCalenderBase::isLeapYear(int year)
201
209
}
202
210
203
211
// 求余数(结果大于0)
204
- int CCalenderBase::getRemainder (int nBase, int nValue) {
212
+ int CCalenderBase::getRemainder (int nBase, int nValue)
213
+ {
205
214
int nRet = nValue % nBase;
206
215
if (nRet < 0 ) {
207
216
nRet += nBase;
@@ -210,7 +219,8 @@ int CCalenderBase::getRemainder(int nBase, int nValue) {
210
219
}
211
220
212
221
// 复制日期
213
- void CCalenderBase::copyDateTime (const CDateTime& datetime, CDateTime& outtime) {
222
+ void CCalenderBase::copyDateTime (const CDateTime& datetime, CDateTime& outtime)
223
+ {
214
224
outtime.m_date .m_nYear = datetime.m_date .m_nYear ;
215
225
outtime.m_date .m_nMon = datetime.m_date .m_nMon ;
216
226
outtime.m_date .m_nDay = datetime.m_date .m_nDay ;
@@ -219,7 +229,6 @@ void CCalenderBase::copyDateTime(const CDateTime& datetime, CDateTime& outtime)
219
229
outtime.m_time .m_nSec = datetime.m_time .m_nSec ;
220
230
}
221
231
222
-
223
232
// 获取四柱
224
233
CGanZhi const & CCalenderBase::getSizhu () const { return m_sizhu; }
225
234
@@ -228,7 +237,8 @@ CJieQi const& CCalenderBase::getJieFirst() const { return m_first; }
228
237
// 获取第二个节气
229
238
CJieQi const & CCalenderBase::getJieSecond () const { return m_second; }
230
239
231
- CGanZhi& CGanZhi::operator =(const CGanZhi& ganzhi) {
240
+ CGanZhi& CGanZhi::operator =(const CGanZhi& ganzhi)
241
+ {
232
242
if (this == &ganzhi) {
233
243
return *this ;
234
244
}
@@ -242,4 +252,4 @@ CGanZhi& CGanZhi::operator=(const CGanZhi& ganzhi) {
242
252
this ->m_nYZhi = ganzhi.m_nYZhi ;
243
253
return *this ;
244
254
}
245
- } // namespace cppbox
255
+ } // namespace cppbox
0 commit comments