#include <DateTime.h>
Definition at line 24 of file DateTime.h.
◆ Date() [1/4]
__DCL_BEGIN_NAMESPACE Date::Date |
( |
| ) |
|
◆ Date() [2/4]
Date::Date |
( |
const Date & | src | ) |
|
◆ Date() [3/4]
Date::Date |
( |
int | nYear, |
|
|
int | nMonth, |
|
|
int | nDay ) |
Definition at line 39 of file DateTime.cpp.
40{
41 assign(nYear, nMonth, nDay);
42}
void assign(int nYear, int nMonth, int nDay)
◆ Date() [4/4]
◆ assign() [1/2]
void Date::assign |
( |
int | nYear, |
|
|
int | nMonth, |
|
|
int | nDay ) |
Definition at line 49 of file DateTime.cpp.
50{
52
54 nYear,
55 nMonth,
56 nDay
57 );
58}
#define __DCL_ASSERT(expr)
static bool isValid(int y, int m, int d)
static long convertGregorianToJulian(int nYear, int nMonth, int nDay)
◆ assign() [2/2]
void Date::assign |
( |
long | nDays | ) |
|
Definition at line 63 of file DateTime.cpp.
64{
65 if (nDays < 0)
67 else if (nDays > 0)
69 else
70
72}
◆ convertGregorianToJulian()
long Date::convertGregorianToJulian |
( |
int | nYear, |
|
|
int | nMonth, |
|
|
int | nDay ) |
|
staticprotected |
Definition at line 285 of file DateTime.cpp.
288{
289 if (y == 0) {
291 return 0;
292 }
293
294 y += 600000;
295
296 int c, ya;
297 if (m > 2)
298 m -= 3;
299 else {
300 m += 9;
301 y--;
302 }
303 c = y / 100;
304 ya = y - 100 * c;
305
306 return (146097 * c) / 4
307 + (1461 * ya) / 4
308 + (153 * m + 2) / 5
309 + d
310 + 1721119;
311}
◆ convertJulianToGregorian()
void Date::convertJulianToGregorian |
( |
long | uJulianDays, |
|
|
int & | nYear, |
|
|
int & | nMonth, |
|
|
int & | nDay ) |
|
staticprotected |
Definition at line 313 of file DateTime.cpp.
317{
318 if (j == 0) {
319 y = 0;
320 m = 0;
321 d = 0;
322 }
323 else {
324 j -= 1721119;
325
326 y = (4 * j - 1) / 146097;
327 j = 4 * j - 1 - 146097 * y;
328 d = j / 4;
329
330 j = (4 * d + 3) / 1461;
331 d = 4 * d + 3 - 1461 * j;
332 d = (d + 4) / 4;
333
334 m = (5 * d - 3) / 153;
335 d = 5 * d - 3 - 153 * m;
336 d = (d + 5 ) / 5;
337
338 y = 100 * y + j;
339 if (m < 10)
340 m += 3;
341 else {
342 m -= 9;
343 y++;
344 }
345
346 y -= 600000;
347 }
348}
◆ day()
Definition at line 204 of file DateTime.cpp.
205{
206 int nYear, nMonth, nDay;
208 return nDay;
209}
static void convertJulianToGregorian(long uJulianDays, int &nYear, int &nMonth, int &nDay)
◆ dayOfWeek()
int Date::dayOfWeek |
( |
| ) |
const |
◆ dayOfYear()
int Date::dayOfYear |
( |
| ) |
const |
◆ days()
long Date::days |
( |
| ) |
const |
◆ daysInMonth()
int Date::daysInMonth |
( |
| ) |
const |
Definition at line 227 of file DateTime.cpp.
228{
229 int nYear, nMonth, nDay;
232 return 29;
233
234 return monthDays[nMonth];
235}
static bool isLeapYear(int nYear)
◆ daysInYear()
int Date::daysInYear |
( |
| ) |
const |
Definition at line 237 of file DateTime.cpp.
238{
239 int nYear, nMonth, nDay;
241
243 return 366;
244 return 365;
245}
◆ decode()
void Date::decode |
( |
int & | nYear, |
|
|
int & | nMonth, |
|
|
int & | nDay ) const |
◆ isLeapYear()
bool Date::isLeapYear |
( |
int | nYear | ) |
|
|
static |
Definition at line 370 of file DateTime.cpp.
371{
372 return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
373}
◆ isValid()
bool Date::isValid |
( |
int | y, |
|
|
int | m, |
|
|
int | d ) |
|
static |
Definition at line 350 of file DateTime.cpp.
351{
352 if (y == 0) {
353
354 if (m == 0 && d == 0)
355 return true;
356 }
357 else {
358 if ((-9999 <= y && y <= 9999) &&
359 (0 < m && m <= 12)
360 && (0 < d)) {
361 if (m == 2 && d == 29)
363 else
364 return d <= monthDays[m];
365 }
366 }
367 return false;
368}
◆ month()
int Date::month |
( |
| ) |
const |
Definition at line 197 of file DateTime.cpp.
198{
199 int nYear, nMonth, nDay;
201 return nMonth;
202}
◆ operator++() [1/2]
const Date & Date::operator++ |
( |
| ) |
|
Definition at line 86 of file DateTime.cpp.
87{
89
92 else
94
95 return *this;
96}
◆ operator++() [2/2]
const Date Date::operator++ |
( |
int | | ) |
|
Definition at line 98 of file DateTime.cpp.
99{
101
103
106 else
108
109 return dSave;
110}
◆ operator+=()
const Date & Date::operator+= |
( |
long | nDays | ) |
|
Definition at line 144 of file DateTime.cpp.
145{
147
150
153 else
155 }
156 else {
158
160
163 else
165 }
166
167
168 return *this;
169}
◆ operator--() [1/2]
const Date & Date::operator-- |
( |
| ) |
|
Definition at line 112 of file DateTime.cpp.
113{
115
118 else
120
121 return *this;
122}
◆ operator--() [2/2]
const Date Date::operator-- |
( |
int | | ) |
|
Definition at line 124 of file DateTime.cpp.
125{
127
129
132 else
134
135 return dSave;
136}
◆ operator-=()
const Date & Date::operator-= |
( |
long | nDays | ) |
|
Definition at line 171 of file DateTime.cpp.
172{
174
176}
const Date & operator+=(long nDays)
◆ operator=()
const Date & Date::operator= |
( |
const Date & | src | ) |
|
◆ toString()
String Date::toString |
( |
| ) |
const |
Definition at line 247 of file DateTime.cpp.
248{
249 int nYear, nMonth, nDay;
250 decode(nYear, nMonth, nDay);
251 return String::format(L"%04d-%02d-%02d", nYear, nMonth, nDay);
252}
void decode(int &nYear, int &nMonth, int &nDay) const
◆ toStringF()
String Date::toStringF |
( |
const wchar_t * | pszFormat = NULL | ) |
const |
Definition at line 256 of file DateTime.cpp.
257{
258 if (!pszFormat)
260
262
263 int nYear, nMonth, nDay;
264 decode(nYear, nMonth, nDay);
265
266 struct tm t;
267 memset(&t, 0, sizeof(struct tm));
268 t.tm_year = nYear - 1900;
269 t.tm_mon = nMonth - 1;
270 t.tm_mday = nDay;
271 t.tm_isdst = -1;
272
276 buf->__dataLength =
n;
277
281}
#define DATETIME_FORMAT_BUFFER_SIZE
void CharsetConvertException *size_t n
static const wchar_t * FORMAT_STRING
◆ year()
Definition at line 190 of file DateTime.cpp.
191{
192 int nYear, nMonth, nDay;
194 return nYear;
195}
◆ FORMAT_STRING
const wchar_t * Date::FORMAT_STRING = L"%Y-%m-%d" |
|
static |
◆ m_nJDay
The documentation for this class was generated from the following files: