#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 | _year, |
|
|
int | _month, |
|
|
int | _day ) |
Definition at line 39 of file DateTime.cpp.
40{
41 assign(_year, _month, _day);
42}
void assign(int _year, int _month, int _day)
◆ Date() [4/4]
◆ assign() [1/2]
| void Date::assign |
( |
int | _year, |
|
|
int | _month, |
|
|
int | _day ) |
Definition at line 49 of file DateTime.cpp.
50{
52
54 _year,
55 _month,
56 _day
57 );
58}
#define __DCL_ASSERT(expr)
static long convertGregorianToJulian(int _year, int _month, int _day)
static bool isValid(int y, int m, int d)
◆ assign() [2/2]
| void Date::assign |
( |
long | _days | ) |
|
Definition at line 63 of file DateTime.cpp.
64{
65 if (_days < 0)
67 else if (_days > 0)
69 else
70
72}
◆ convertGregorianToJulian()
| long Date::convertGregorianToJulian |
( |
int | _year, |
|
|
int | _month, |
|
|
int | _day ) |
|
staticprotected |
Definition at line 293 of file DateTime.cpp.
296{
297 if (_y == 0) {
299 return 0;
300 }
301
302 _y += 600000;
303
304 int c, ya;
305 if (_m > 2)
306 _m -= 3;
307 else {
308 _m += 9;
309 _y--;
310 }
311 c = _y / 100;
312 ya = _y - 100 * c;
313
314 return (146097 * c) / 4
315 + (1461 * ya) / 4
316 + (153 * _m + 2) / 5
317 + _d
318 + 1721119;
319}
◆ convertJulianToGregorian()
| void Date::convertJulianToGregorian |
( |
long | uJulianDays, |
|
|
int & | _year, |
|
|
int & | _month, |
|
|
int & | _day ) |
|
staticprotected |
Definition at line 321 of file DateTime.cpp.
325{
326 if (_j == 0) {
327 _y = 0;
328 _m = 0;
329 _d = 0;
330 }
331 else {
332 _j -= 1721119;
333
334 _y = (4 * _j - 1) / 146097;
335 _j = 4 * _j - 1 - 146097 * _y;
336 _d = _j / 4;
337
338 _j = (4 * _d + 3) / 1461;
339 _d = 4 * _d + 3 - 1461 * _j;
340 _d = (_d + 4) / 4;
341
342 _m = (5 * _d - 3) / 153;
343 _d = 5 * _d - 3 - 153 * _m;
344 _d = (_d + 5 ) / 5;
345
346 _y = 100 * _y + _j;
347 if (_m < 10)
348 _m += 3;
349 else {
350 _m -= 9;
351 _y++;
352 }
353
354 _y -= 600000;
355 }
356}
◆ day()
Definition at line 203 of file DateTime.cpp.
204{
208}
static void convertJulianToGregorian(long uJulianDays, int &_year, int &_month, int &_day)
◆ dayOfWeek()
| int Date::dayOfWeek |
( |
| ) |
const |
◆ dayOfYear()
| int Date::dayOfYear |
( |
| ) |
const |
◆ days()
| long Date::days |
( |
| ) |
const |
◆ daysInMonth()
| int Date::daysInMonth |
( |
| ) |
const |
Definition at line 226 of file DateTime.cpp.
227{
231 return 29;
232
233 return __monthDays__[
month];
234}
static bool isLeapYear(int _year)
◆ daysInYear()
| int Date::daysInYear |
( |
| ) |
const |
Definition at line 236 of file DateTime.cpp.
237{
240
242 return 366;
243 return 365;
244}
◆ decode()
| void Date::decode |
( |
int & | _year, |
|
|
int & | _month, |
|
|
int & | _day ) const |
◆ isLeapYear()
| bool Date::isLeapYear |
( |
int | _year | ) |
|
|
static |
Definition at line 378 of file DateTime.cpp.
379{
380 return (_y % 4 == 0 && _y % 100 != 0) || _y % 400 == 0;
381}
◆ isValid()
| bool Date::isValid |
( |
int | y, |
|
|
int | m, |
|
|
int | d ) |
|
static |
Definition at line 358 of file DateTime.cpp.
359{
360 if (_y == 0) {
361
362 if (_m == 0 && _d == 0)
363 return true;
364 }
365 else {
366 if ((-9999 <= _y && _y <= 9999) &&
367 (0 < _m && _m <= 12)
368 && (0 < _d)) {
369 if (_m == 2 && _d == 29)
371 else
372 return _d <= __monthDays__[_m];
373 }
374 }
375 return false;
376}
◆ month()
| int Date::month |
( |
| ) |
const |
◆ 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
110}
◆ operator+=()
| const Date & Date::operator+= |
( |
long | _days | ) |
|
Definition at line 144 of file DateTime.cpp.
145{
147
150
153 else
155 }
156 else {
158
160
163 else
165 }
166
167 return *this;
168}
◆ 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
136}
◆ operator-=()
| const Date & Date::operator-= |
( |
long | _days | ) |
|
Definition at line 170 of file DateTime.cpp.
171{
173
175}
const Date & operator+=(long _days)
◆ operator=()
| const Date & Date::operator= |
( |
const Date & | _src | ) |
|
◆ toString()
| String Date::toString |
( |
| ) |
const |
Definition at line 251 of file DateTime.cpp.
252{
258 }
260}
void decode(int &_year, int &_month, int &_day) const
◆ toStringF()
| String Date::toStringF |
( |
const wchar_t * | _format = NULL | ) |
const |
Definition at line 264 of file DateTime.cpp.
265{
266 if (!_format)
268
270
273
274 struct tm _time;
275 memset(&_time, 0, sizeof(struct tm));
276 _time.tm_year =
year - 1900;
277 _time.tm_mon =
month - 1;
279 _time.tm_isdst = -1;
280
284 buf->__dataLength = n;
285
287 buf->release();
289}
#define DATETIME_FORMAT_BUFFER_SIZE
static const wchar_t * FORMAT_STRING
◆ year()
◆ __jday
◆ FORMAT_STRING
| const wchar_t * Date::FORMAT_STRING = L"%Y-%m-%d" |
|
static |
The documentation for this class was generated from the following files: