17#if __DCL_HAVE_ALLOC_DEBUG
18#undef __DCL_ALLOC_LEVEL
19#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
41 assign(nYear, nMonth, nDay);
60#define AD_START 220866926
61#define BC_END (AD_START - 367)
192 int nYear, nMonth, nDay;
199 int nYear, nMonth, nDay;
206 int nYear, nMonth, nDay;
213 return (((
m_nJDay + 1) % 7) + 7) % 7 + 1;
221static const int monthDays[] =
224 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
229 int nYear, nMonth, nDay;
234 return monthDays[nMonth];
239 int nYear, nMonth, nDay;
249 int nYear, nMonth, nDay;
250 decode(nYear, nMonth, nDay);
251 return String::format(L
"%04d-%02d-%02d", nYear, nMonth, nDay);
263 int nYear, nMonth, nDay;
264 decode(nYear, nMonth, nDay);
267 memset(&t, 0,
sizeof(
struct tm));
268 t.tm_year = nYear - 1900;
269 t.tm_mon = nMonth - 1;
276 buf->__dataLength =
n;
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(nHour, nMin, nSec, nMSec);
490 return String::format(L
"%02d:%02d:%02d.%03d",
508 memset(&t, 0,
sizeof(
struct tm));
517 buf->__dataLength =
n;
527 return (0 <= nHour && nHour <= 23)
528 && (0 <= nMin && nMin <= 59)
529 && (0 <= nSec && nSec <= 59)
530 && (0 <= nMSec && nMSec <= 999);
548 assign(nDays, nMilliSeconds);
552 int nHours,
int nMinutes,
int nSeconds,
556 assign(nDays, nHours, nMinutes, nSeconds, nMilliSeconds);
561 assign(nTotalMilliSeconds);
570 int nHours,
int nMinutes,
int nSeconds,
620 int& nHours,
int& nMinutes,
int& nSeconds,
683 return String::format(L
"-%ld %02d:%02d:%02d.%03d",
689 return String::format(L
"+%ld %02d:%02d:%02d.%03d",
717 int nHour,
int nMin,
int nSec,
int nMSec )
719 m_date.assign(nYear, nMonth, nDay);
720 m_time.assign(nHour, nMin, nSec, nMSec);
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 nHour,
int nMin,
int nSec,
int nMSec )
757 m_date.assign(nYear, nMonth, nDay);
758 m_time.assign(nHour, nMin, nSec, nMSec);
772 + (int64_t)
m_time.totalMilliSeconds()
784 + (int64_t)
m_time.totalMilliSeconds()
841 int nYear, nMonth, nDay, nHour, nMin, nSec, nMSec;
842 m_date.decode(nYear, nMonth, nDay);
843 m_time.decode(nHour, nMin, nSec, nMSec);
846 t.tm_year = nYear - 1900;
847 t.tm_mon = nMonth - 1;
860 buf->__dataLength =
n;
888 Date dt(t.wYear, t.wMonth, t.wDay);
889 int64_t
r = dt.
days() * 24;
890 r = (
r + t.wHour) * 60;
891 r = (
r + t.wMinute) * 60;
892 r = (
r + t.wSecond) * 1000;
893 r += t.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 + ((t.time - t.timezone * 60) /
SEC_PER_DAY))
957 localtime_r(&timer, &tm);
960 gettimeofday(&tv,
NULL);
977 const char* pszDateTimeString,
978 const char* pszFormat
985 memset(&tm, 0,
sizeof(tm));
986 const char* p = strptime(pszDateTimeString, pszFormat, &tm);
994 p - pszDateTimeString
DCLCAPI Interval operator-(const Interval &iv1, const Interval &iv2)
DCLCAPI Date operator+(const Date &d, long nDays)
#define DATETIME_FORMAT_BUFFER_SIZE
#define __DCL_ASSERT(expr)
void CharsetConvertException *size_t n
void assign(int nYear, int nMonth, int nDay)
void decode(int &nYear, int &nMonth, int &nDay) const
const Date & operator--()
static bool isLeapYear(int nYear)
static bool isValid(int y, int m, int d)
static const wchar_t * FORMAT_STRING
String toStringF(const wchar_t *pszFormat=NULL) const
const Date & operator++()
static long convertGregorianToJulian(int nYear, int nMonth, int nDay)
static void convertJulianToGregorian(long uJulianDays, int &nYear, int &nMonth, int &nDay)
const Date & operator-=(long nDays)
const Date & operator=(const Date &src)
const Date & operator+=(long nDays)
static int compare(const DateTime &dt1, const DateTime &dt2)
String toStringF(const wchar_t *pszFormat=NULL) const
const DateTime & operator+=(const Interval &iv)
const DateTime & operator-=(const Interval &iv)
const DateTime & operator=(const DateTime &src)
static const wchar_t * FORMAT_STRING
static DateTime getCurrentUTCTime()
static int64_t getCurrentTimeMillis()
static DateTime getCurrentLocalTime()
int64_t totalHours() const
int64_t totalMinutes() const
int64_t totalSeconds() const
const Interval & operator-=(const Interval &iv)
const Interval & operator+=(const Interval &iv)
const Interval & operator=(const Interval &src)
void assign(int nDays, int nMilliSeconds)
void decode(long &nDays, int &nHours, int &nMinutes, int &nSeconds, int &nMilliSeconds) const
int64_t totalMilliSeconds() const
const Time & operator-=(long nMilliSeconds)
const Time & operator=(const Time &src)
static const wchar_t * FORMAT_STRING
void decode(int &nHour, int &nMin, int &nSec, int &nMSec) const
void assign(int nHour, int nMin, int nSec, int nMSec=0)
static bool isValid(int nHour, int nMin, int nSec, int nMSec)
long totalMilliSeconds() const
const Time & operator+=(long nMilliSeconds)
String toStringF(const wchar_t *pszFormat=NULL)
unsigned long m_uMilliSeconds