17#if __DCL_HAVE_ALLOC_DEBUG
18#undef __DCL_ALLOC_LEVEL
19#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
41 assign(_year, _month, _day);
60#define AD_START 220866926
61#define BC_END (AD_START - 367)
213 return (((
__jday + 1) % 7) + 7) % 7 + 1;
221static const int __monthDays__[] =
224 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
234 return __monthDays__[
month];
251 return String::format(L
"%04d-%02d-%02d",
year,
month,
day);
267 memset(&_time, 0,
sizeof(
struct tm));
268 _time.tm_year =
year - 1900;
269 _time.tm_mon =
month - 1;
276 buf->__dataLength =
n;
286 int _y,
int _m,
int _d
306 return (146097 * c) / 4
315 int& _y,
int& _m,
int& _d
326 _y = (4 * _j - 1) / 146097;
327 _j = 4 * _j - 1 - 146097 * _y;
330 _j = (4 * _d + 3) / 1461;
331 _d = 4 * _d + 3 - 1461 * _j;
334 _m = (5 * _d - 3) / 153;
335 _d = 5 * _d - 3 - 153 * _m;
354 if (_m == 0 && _d == 0)
358 if ((-9999 <= _y && _y <= 9999) &&
361 if (_m == 2 && _d == 29)
364 return _d <= __monthDays__[_m];
372 return (_y % 4 == 0 && _y % 100 != 0) || _y % 400 == 0;
389#define SEC_PER_DAY 86400
390#define MSEC_PER_DAY 86400000
391#define SEC_PER_HOUR 3600
392#define MSEC_PER_HOUR 3600000
393#define SEC_PER_MIN 60
394#define MSEC_PER_MIN 60000
398 assign(_hour, _min, _sec, _millisecond);
459void Time::decode(
int& _hour,
int& _min,
int& _sec,
int& _millisecond)
const
490 return String::format(L
"%02d:%02d:%02d.%03d",
508 memset(&_time, 0,
sizeof(
struct tm));
509 _time.tm_hour =
hour();
517 buf->__dataLength =
n;
527 return (0 <= _hour && _hour <= 23)
528 && (0 <= _min && _min <= 59)
529 && (0 <= _sec && _sec <= 59)
530 && (0 <= _millisecond && _millisecond <= 999);
548 assign(_days, _milliseconds);
552 int _hours,
int _minutes,
int _seconds,
556 assign(_days, _hours, _minutes, _seconds, _milliseconds);
570 int _hours,
int _minutes,
int _seconds,
620 int& _hours,
int& _minutes,
int& _seconds,
683 return String::format(L
"-%ld %02d:%02d:%02d.%03d",
689 return String::format(L
"+%ld %02d:%02d:%02d.%03d",
717 int _hour,
int _min,
int _sec,
int _millisecond )
719 __date.assign(_year, _month, _day);
720 __time.assign(_hour, _min, _sec, _millisecond);
729 _get_timezone(&seconds);
730 tm_gmtoff = -seconds;
733 localtime_r(&_timer, &tm);
734 tm_gmtoff = tm.tm_gmtoff;
738 (
long) (719163 + ((_timer + tm_gmtoff) /
SEC_PER_DAY))
755 int _hour,
int _min,
int _sec,
int _millisecond )
757 __date.assign(_year, _month, _day);
758 __time.assign(_hour, _min, _sec, _millisecond);
772 + (int64_t)
__time.totalMilliSeconds()
784 + (int64_t)
__time.totalMilliSeconds()
841 int year, month, day, hour, min, sec, msec;
842 __date.decode(year, month, day);
843 __time.decode(hour, min, sec, msec);
846 time.tm_year = year - 1900;
847 time.tm_mon = month - 1;
860 buf->__dataLength =
n;
886 GetSystemTime(&
time);
889 int64_t
r = dt.
days() * 24;
890 r = (
r +
time.wHour) * 60;
891 r = (
r +
time.wMinute) * 60;
892 r = (
r +
time.wSecond) * 1000;
893 r +=
time.wMilliseconds;
897 gettimeofday(&tv,
NULL);
898 int64_t
r = tv.tv_sec * 1000;
899 r += tv.tv_usec / 1000;
922 gettimeofday(&tv,
NULL);
945 (
long) (719163 + ((timeb.time - timeb.timezone * 60) /
SEC_PER_DAY))
957 localtime_r(&timer, &tm);
960 gettimeofday(&tv,
NULL);
977 const char* pszDateTimeString,
985 memset(&tm, 0,
sizeof(tm));
986 const char* p = strptime(pszDateTimeString, _format, &tm);
994 p - pszDateTimeString
DCLCAPI Interval operator-(const Interval &_iv1, const Interval &_iv2)
DCLCAPI Date operator+(const Date &_date, long _days)
#define DATETIME_FORMAT_BUFFER_SIZE
#define __DCL_ASSERT(expr)
void CharsetConvertException *size_t n
const Date & operator=(const Date &_src)
const Date & operator--()
void assign(int _year, int _month, int _day)
static long convertGregorianToJulian(int _year, int _month, int _day)
static bool isValid(int y, int m, int d)
static void convertJulianToGregorian(long uJulianDays, int &_year, int &_month, int &_day)
String toStringF(const wchar_t *_format=NULL) const
static const wchar_t * FORMAT_STRING
const Date & operator++()
const Date & operator+=(long _days)
void decode(int &_year, int &_month, int &_day) const
const Date & operator-=(long _days)
static bool isLeapYear(int _year)
const DateTime & operator+=(const Interval &_iv)
void assign(time_t _timer)
const DateTime & operator=(const DateTime &_src)
static const wchar_t * FORMAT_STRING
static DateTime getCurrentUTCTime()
static int64_t getCurrentTimeMillis()
String toStringF(const wchar_t *_format=NULL) const
static DateTime getCurrentLocalTime()
static int compare(const DateTime &_dt1, const DateTime &_dt2)
const DateTime & operator-=(const Interval &_iv)
int64_t totalHours() const
int64_t totalMinutes() const
void assign(int _days, int _milliseconds)
int64_t totalSeconds() const
void decode(long &_days, int &_hours, int &_minutes, int &_seconds, int &_milliseconds) const
int64_t totalMilliSeconds() const
const Interval & operator-=(const Interval &_iv)
const Interval & operator+=(const Interval &_iv)
const Interval & operator=(const Interval &_src)
String toStringF(const wchar_t *_format=NULL)
const Time & operator=(const Time &_src)
void decode(int &_hour, int &_min, int &_sec, int &_millisecond) const
static const wchar_t * FORMAT_STRING
static bool isValid(int _hour, int _min, int _sec, int _millisecond)
const Time & operator-=(long _milliseconds)
unsigned long __milliseconds
void assign(int _hour, int _min, int _sec, int _millisecond=0)
long totalMilliSeconds() const
const Time & operator+=(long _milliseconds)