#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 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 & | _year, |
|
|
int & | _month, |
|
|
int & | _day ) |
|
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{
209}
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 227 of file DateTime.cpp.
228{
232 return 29;
233
234 return __monthDays__[
month];
235}
static bool isLeapYear(int _year)
◆ daysInYear()
| int Date::daysInYear |
( |
| ) |
const |
Definition at line 237 of file DateTime.cpp.
238{
241
243 return 366;
244 return 365;
245}
◆ decode()
| void Date::decode |
( |
int & | _year, |
|
|
int & | _month, |
|
|
int & | _day ) const |
◆ isLeapYear()
| bool Date::isLeapYear |
( |
int | _year | ) |
|
|
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 |
◆ 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
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
136}
◆ operator-=()
| const Date & Date::operator-= |
( |
long | _days | ) |
|
Definition at line 171 of file DateTime.cpp.
172{
174
176}
const Date & operator+=(long _days)
◆ operator=()
| const Date & Date::operator= |
( |
const Date & | _src | ) |
|
◆ toString()
| String Date::toString |
( |
| ) |
const |
Definition at line 247 of file DateTime.cpp.
248{
251 return String::format(L
"%04d-%02d-%02d",
year,
month,
day);
252}
void decode(int &_year, int &_month, int &_day) const
◆ toStringF()
| String Date::toStringF |
( |
const wchar_t * | _format = NULL | ) |
const |
Definition at line 256 of file DateTime.cpp.
257{
258 if (!_format)
260
262
265
266 struct tm _time;
267 memset(&_time, 0, sizeof(struct tm));
268 _time.tm_year =
year - 1900;
269 _time.tm_mon =
month - 1;
271 _time.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()
◆ __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: