summaryrefslogtreecommitdiff
path: root/xfa/src/fgas/include/fx_datetime.h
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2015-08-04 13:00:21 -0700
committerNico Weber <thakis@chromium.org>2015-08-04 13:00:21 -0700
commit9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f (patch)
treec97037f398d714665aefccb6eb54d0969ad7030c /xfa/src/fgas/include/fx_datetime.h
parent780cee82236d1b3b0f9b01a22424e4b8ec9a6f12 (diff)
downloadpdfium-9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f.tar.xz
XFA: clang-format all pdfium code.
No behavior change. Generated by: find . -name '*.cpp' -o -name '*.h' | \ grep -E -v 'third_party|thirdparties|lpng_v163|tiff_v403' | \ xargs ../../buildtools/mac/clang-format -i Then manually merged https://codereview.chromium.org/1269223002/ See thread "tabs vs spaces" on pdfium@googlegroups.com for discussion. BUG=none
Diffstat (limited to 'xfa/src/fgas/include/fx_datetime.h')
-rw-r--r--xfa/src/fgas/include/fx_datetime.h801
1 files changed, 361 insertions, 440 deletions
diff --git a/xfa/src/fgas/include/fx_datetime.h b/xfa/src/fgas/include/fx_datetime.h
index b867b369d2..d723b4367e 100644
--- a/xfa/src/fgas/include/fx_datetime.h
+++ b/xfa/src/fgas/include/fx_datetime.h
@@ -8,464 +8,385 @@
#define _FX_DATETIME_H_
class CFX_Unitime;
class CFX_DateTime;
-typedef int64_t FX_UNITIME;
+typedef int64_t FX_UNITIME;
enum FX_WEEKDAY {
- FX_Sunday = 0,
- FX_Monday ,
- FX_Tuesday ,
- FX_Wednesday ,
- FX_Thursday ,
- FX_Friday ,
- FX_Saturday ,
+ FX_Sunday = 0,
+ FX_Monday,
+ FX_Tuesday,
+ FX_Wednesday,
+ FX_Thursday,
+ FX_Friday,
+ FX_Saturday,
};
-FX_BOOL FX_IsLeapYear(int32_t iYear);
-int32_t FX_DaysInYear(int32_t iYear);
-uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth);
-class CFX_Unitime
-{
-public:
- CFX_Unitime()
- {
- m_iUnitime = 0;
- }
- CFX_Unitime(FX_UNITIME iUnitime)
- {
- m_iUnitime = iUnitime;
- }
- CFX_Unitime(const CFX_Unitime &unitime)
- {
- m_iUnitime = unitime.m_iUnitime;
- }
- operator FX_UNITIME * ()
- {
- return &m_iUnitime;
- }
- operator FX_UNITIME const * () const
- {
- return &m_iUnitime;
- }
- operator FX_UNITIME& ()
- {
- return m_iUnitime;
- }
- operator const FX_UNITIME& () const
- {
- return m_iUnitime;
- }
- CFX_Unitime& operator = (const CFX_Unitime &t)
- {
- m_iUnitime = t.m_iUnitime;
- return *this;
- }
- CFX_Unitime& operator = (FX_UNITIME t)
- {
- m_iUnitime = t;
- return *this;
- }
- CFX_Unitime& operator += (const CFX_Unitime &t)
- {
- m_iUnitime += t.m_iUnitime;
- return *this;
- }
- CFX_Unitime& operator += (FX_UNITIME t)
- {
- m_iUnitime += t;
- return *this;
- }
- CFX_Unitime& operator -= (const CFX_Unitime &t)
- {
- m_iUnitime -= t.m_iUnitime;
- return *this;
- }
- CFX_Unitime& operator -= (FX_UNITIME t)
- {
- m_iUnitime -= t;
- return *this;
- }
- void Now();
- void SetGMTime();
- void Set(int32_t year, uint8_t month, uint8_t day, uint8_t hour = 0, uint8_t minute = 0, uint8_t second = 0, FX_WORD millisecond = 0);
- void Set(FX_UNITIME t);
- int32_t GetYear() const;
- uint8_t GetMonth() const;
- uint8_t GetDay() const;
- FX_WEEKDAY GetDayOfWeek() const;
- FX_WORD GetDayOfYear() const;
- int64_t GetDayOfAD() const;
- uint8_t GetHour() const;
- uint8_t GetMinute() const;
- uint8_t GetSecond() const;
- FX_WORD GetMillisecond() const;
- FX_BOOL AddYears(int32_t iYears);
- FX_BOOL AddMonths(int32_t iMonths);
- FX_BOOL AddDays(int32_t iDays);
- FX_BOOL AddHours(int32_t iHours);
- FX_BOOL AddMinutes(int32_t iMinutes);
- FX_BOOL AddSeconds(int32_t iSeconds);
- FX_BOOL AddMilliseconds(int32_t iMilliseconds);
- friend CFX_Unitime operator + (const CFX_Unitime &t1, const CFX_Unitime &t2)
- {
- return CFX_Unitime(t1.m_iUnitime + t2.m_iUnitime);
- }
- friend CFX_Unitime operator + (const CFX_Unitime &t1, FX_UNITIME t2)
- {
- return CFX_Unitime(t1.m_iUnitime + t2);
- }
- friend CFX_Unitime operator + (FX_UNITIME t1, const CFX_Unitime &t2)
- {
- return CFX_Unitime(t1 + t2.m_iUnitime);
- }
- friend CFX_Unitime operator - (const CFX_Unitime &t1, const CFX_Unitime &t2)
- {
- return CFX_Unitime(t1.m_iUnitime + t2.m_iUnitime);
- }
- friend CFX_Unitime operator - (const CFX_Unitime &t1, FX_UNITIME t2)
- {
- return CFX_Unitime(t1.m_iUnitime + t2);
- }
- friend CFX_Unitime operator - (FX_UNITIME t1, const CFX_Unitime &t2)
- {
- return CFX_Unitime(t1 + t2.m_iUnitime);
- }
- friend FX_BOOL operator == (const CFX_Unitime &t1, const CFX_Unitime &t2)
- {
- return t1.m_iUnitime == t2.m_iUnitime;
- }
- friend FX_BOOL operator == (const CFX_Unitime &t1, FX_UNITIME t2)
- {
- return t1.m_iUnitime == t2;
- }
- friend FX_BOOL operator == (FX_UNITIME t1, const CFX_Unitime &t2)
- {
- return t1 == t2.m_iUnitime;
- }
- friend FX_BOOL operator != (const CFX_Unitime &t1, const CFX_Unitime &t2)
- {
- return t1.m_iUnitime != t2.m_iUnitime;
- }
- friend FX_BOOL operator != (const CFX_Unitime &t1, FX_UNITIME t2)
- {
- return t1.m_iUnitime != t2;
- }
- friend FX_BOOL operator != (FX_UNITIME t1, const CFX_Unitime &t2)
- {
- return t1 != t2.m_iUnitime;
- }
- friend FX_BOOL operator > (const CFX_Unitime &t1, const CFX_Unitime &t2)
- {
- return t1.m_iUnitime > t2.m_iUnitime;
- }
- friend FX_BOOL operator > (const CFX_Unitime &t1, FX_UNITIME t2)
- {
- return t1.m_iUnitime > t2;
- }
- friend FX_BOOL operator > (FX_UNITIME t1, const CFX_Unitime &t2)
- {
- return t1 > t2.m_iUnitime;
- }
- friend FX_BOOL operator >= (const CFX_Unitime &t1, const CFX_Unitime &t2)
- {
- return t1.m_iUnitime >= t2.m_iUnitime;
- }
- friend FX_BOOL operator >= (const CFX_Unitime &t1, FX_UNITIME t2)
- {
- return t1.m_iUnitime >= t2;
- }
- friend FX_BOOL operator >= (FX_UNITIME t1, const CFX_Unitime &t2)
- {
- return t1 >= t2.m_iUnitime;
- }
- friend FX_BOOL operator < (const CFX_Unitime &t1, const CFX_Unitime &t2)
- {
- return t1.m_iUnitime < t2.m_iUnitime;
- }
- friend FX_BOOL operator < (const CFX_Unitime &t1, FX_UNITIME t2)
- {
- return t1.m_iUnitime < t2;
- }
- friend FX_BOOL operator < (FX_UNITIME t1, const CFX_Unitime &t2)
- {
- return t1 < t2.m_iUnitime;
- }
- friend FX_BOOL operator <= (const CFX_Unitime &t1, const CFX_Unitime &t2)
- {
- return t1.m_iUnitime <= t2.m_iUnitime;
- }
- friend FX_BOOL operator <= (const CFX_Unitime &t1, FX_UNITIME t2)
- {
- return t1.m_iUnitime <= t2;
- }
- friend FX_BOOL operator <= (FX_UNITIME t1, const CFX_Unitime &t2)
- {
- return t1 <= t2.m_iUnitime;
- }
-private:
- FX_UNITIME m_iUnitime;
+FX_BOOL FX_IsLeapYear(int32_t iYear);
+int32_t FX_DaysInYear(int32_t iYear);
+uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth);
+class CFX_Unitime {
+ public:
+ CFX_Unitime() { m_iUnitime = 0; }
+ CFX_Unitime(FX_UNITIME iUnitime) { m_iUnitime = iUnitime; }
+ CFX_Unitime(const CFX_Unitime& unitime) { m_iUnitime = unitime.m_iUnitime; }
+ operator FX_UNITIME*() { return &m_iUnitime; }
+ operator FX_UNITIME const*() const { return &m_iUnitime; }
+ operator FX_UNITIME&() { return m_iUnitime; }
+ operator const FX_UNITIME&() const { return m_iUnitime; }
+ CFX_Unitime& operator=(const CFX_Unitime& t) {
+ m_iUnitime = t.m_iUnitime;
+ return *this;
+ }
+ CFX_Unitime& operator=(FX_UNITIME t) {
+ m_iUnitime = t;
+ return *this;
+ }
+ CFX_Unitime& operator+=(const CFX_Unitime& t) {
+ m_iUnitime += t.m_iUnitime;
+ return *this;
+ }
+ CFX_Unitime& operator+=(FX_UNITIME t) {
+ m_iUnitime += t;
+ return *this;
+ }
+ CFX_Unitime& operator-=(const CFX_Unitime& t) {
+ m_iUnitime -= t.m_iUnitime;
+ return *this;
+ }
+ CFX_Unitime& operator-=(FX_UNITIME t) {
+ m_iUnitime -= t;
+ return *this;
+ }
+ void Now();
+ void SetGMTime();
+ void Set(int32_t year,
+ uint8_t month,
+ uint8_t day,
+ uint8_t hour = 0,
+ uint8_t minute = 0,
+ uint8_t second = 0,
+ FX_WORD millisecond = 0);
+ void Set(FX_UNITIME t);
+ int32_t GetYear() const;
+ uint8_t GetMonth() const;
+ uint8_t GetDay() const;
+ FX_WEEKDAY GetDayOfWeek() const;
+ FX_WORD GetDayOfYear() const;
+ int64_t GetDayOfAD() const;
+ uint8_t GetHour() const;
+ uint8_t GetMinute() const;
+ uint8_t GetSecond() const;
+ FX_WORD GetMillisecond() const;
+ FX_BOOL AddYears(int32_t iYears);
+ FX_BOOL AddMonths(int32_t iMonths);
+ FX_BOOL AddDays(int32_t iDays);
+ FX_BOOL AddHours(int32_t iHours);
+ FX_BOOL AddMinutes(int32_t iMinutes);
+ FX_BOOL AddSeconds(int32_t iSeconds);
+ FX_BOOL AddMilliseconds(int32_t iMilliseconds);
+ friend CFX_Unitime operator+(const CFX_Unitime& t1, const CFX_Unitime& t2) {
+ return CFX_Unitime(t1.m_iUnitime + t2.m_iUnitime);
+ }
+ friend CFX_Unitime operator+(const CFX_Unitime& t1, FX_UNITIME t2) {
+ return CFX_Unitime(t1.m_iUnitime + t2);
+ }
+ friend CFX_Unitime operator+(FX_UNITIME t1, const CFX_Unitime& t2) {
+ return CFX_Unitime(t1 + t2.m_iUnitime);
+ }
+ friend CFX_Unitime operator-(const CFX_Unitime& t1, const CFX_Unitime& t2) {
+ return CFX_Unitime(t1.m_iUnitime + t2.m_iUnitime);
+ }
+ friend CFX_Unitime operator-(const CFX_Unitime& t1, FX_UNITIME t2) {
+ return CFX_Unitime(t1.m_iUnitime + t2);
+ }
+ friend CFX_Unitime operator-(FX_UNITIME t1, const CFX_Unitime& t2) {
+ return CFX_Unitime(t1 + t2.m_iUnitime);
+ }
+ friend FX_BOOL operator==(const CFX_Unitime& t1, const CFX_Unitime& t2) {
+ return t1.m_iUnitime == t2.m_iUnitime;
+ }
+ friend FX_BOOL operator==(const CFX_Unitime& t1, FX_UNITIME t2) {
+ return t1.m_iUnitime == t2;
+ }
+ friend FX_BOOL operator==(FX_UNITIME t1, const CFX_Unitime& t2) {
+ return t1 == t2.m_iUnitime;
+ }
+ friend FX_BOOL operator!=(const CFX_Unitime& t1, const CFX_Unitime& t2) {
+ return t1.m_iUnitime != t2.m_iUnitime;
+ }
+ friend FX_BOOL operator!=(const CFX_Unitime& t1, FX_UNITIME t2) {
+ return t1.m_iUnitime != t2;
+ }
+ friend FX_BOOL operator!=(FX_UNITIME t1, const CFX_Unitime& t2) {
+ return t1 != t2.m_iUnitime;
+ }
+ friend FX_BOOL operator>(const CFX_Unitime& t1, const CFX_Unitime& t2) {
+ return t1.m_iUnitime > t2.m_iUnitime;
+ }
+ friend FX_BOOL operator>(const CFX_Unitime& t1, FX_UNITIME t2) {
+ return t1.m_iUnitime > t2;
+ }
+ friend FX_BOOL operator>(FX_UNITIME t1, const CFX_Unitime& t2) {
+ return t1 > t2.m_iUnitime;
+ }
+ friend FX_BOOL operator>=(const CFX_Unitime& t1, const CFX_Unitime& t2) {
+ return t1.m_iUnitime >= t2.m_iUnitime;
+ }
+ friend FX_BOOL operator>=(const CFX_Unitime& t1, FX_UNITIME t2) {
+ return t1.m_iUnitime >= t2;
+ }
+ friend FX_BOOL operator>=(FX_UNITIME t1, const CFX_Unitime& t2) {
+ return t1 >= t2.m_iUnitime;
+ }
+ friend FX_BOOL operator<(const CFX_Unitime& t1, const CFX_Unitime& t2) {
+ return t1.m_iUnitime < t2.m_iUnitime;
+ }
+ friend FX_BOOL operator<(const CFX_Unitime& t1, FX_UNITIME t2) {
+ return t1.m_iUnitime < t2;
+ }
+ friend FX_BOOL operator<(FX_UNITIME t1, const CFX_Unitime& t2) {
+ return t1 < t2.m_iUnitime;
+ }
+ friend FX_BOOL operator<=(const CFX_Unitime& t1, const CFX_Unitime& t2) {
+ return t1.m_iUnitime <= t2.m_iUnitime;
+ }
+ friend FX_BOOL operator<=(const CFX_Unitime& t1, FX_UNITIME t2) {
+ return t1.m_iUnitime <= t2;
+ }
+ friend FX_BOOL operator<=(FX_UNITIME t1, const CFX_Unitime& t2) {
+ return t1 <= t2.m_iUnitime;
+ }
+
+ private:
+ FX_UNITIME m_iUnitime;
};
#if _FX_OS_ != _FX_ANDROID_
#pragma pack(push, 1)
#endif
typedef struct _FX_DATE {
- int32_t year;
- uint8_t month;
- uint8_t day;
-} FX_DATE, * FX_LPDATE;
-typedef FX_DATE const * FX_LPCDATE;
+ int32_t year;
+ uint8_t month;
+ uint8_t day;
+} FX_DATE, *FX_LPDATE;
+typedef FX_DATE const* FX_LPCDATE;
typedef struct _FX_TIME {
- uint8_t hour;
- uint8_t minute;
- uint8_t second;
- FX_WORD millisecond;
-} FX_TIME, * FX_LPTIME;
-typedef FX_TIME const * FX_LPCTIME;
+ uint8_t hour;
+ uint8_t minute;
+ uint8_t second;
+ FX_WORD millisecond;
+} FX_TIME, *FX_LPTIME;
+typedef FX_TIME const* FX_LPCTIME;
typedef struct _FX_TIMEZONE {
- int8_t tzHour;
- uint8_t tzMinute;
-} FX_TIMEZONE, * FX_LPTIMEZONE;
-typedef FX_TIMEZONE const * FX_LPCTIMEZONE;
+ int8_t tzHour;
+ uint8_t tzMinute;
+} FX_TIMEZONE, *FX_LPTIMEZONE;
+typedef FX_TIMEZONE const* FX_LPCTIMEZONE;
typedef struct _FX_DATETIME {
- union {
- struct {
- int32_t year;
- uint8_t month;
- uint8_t day;
- } sDate;
- FX_DATE aDate;
- } Date;
- union {
- struct {
- uint8_t hour;
- uint8_t minute;
- uint8_t second;
- FX_WORD millisecond;
- } sTime;
- FX_TIME aTime;
- } Time;
-} FX_DATETIME, * FX_LPDATETIME;
-typedef FX_DATETIME const * FX_LPCDATETIME;
+ union {
+ struct {
+ int32_t year;
+ uint8_t month;
+ uint8_t day;
+ } sDate;
+ FX_DATE aDate;
+ } Date;
+ union {
+ struct {
+ uint8_t hour;
+ uint8_t minute;
+ uint8_t second;
+ FX_WORD millisecond;
+ } sTime;
+ FX_TIME aTime;
+ } Time;
+} FX_DATETIME, *FX_LPDATETIME;
+typedef FX_DATETIME const* FX_LPCDATETIME;
typedef struct _FX_DATETIMEZONE {
- union {
+ union {
+ struct {
+ union {
struct {
- union {
- struct {
- int32_t year;
- uint8_t month;
- uint8_t day;
- };
- FX_DATE date;
- };
- union {
- struct {
- uint8_t hour;
- uint8_t minute;
- uint8_t second;
- FX_WORD millisecond;
- };
- FX_TIME time;
- };
+ int32_t year;
+ uint8_t month;
+ uint8_t day;
};
- FX_DATETIME dt;
- };
- union {
+ FX_DATE date;
+ };
+ union {
struct {
- int8_t tzHour;
- uint8_t tzMinute;
+ uint8_t hour;
+ uint8_t minute;
+ uint8_t second;
+ FX_WORD millisecond;
};
- FX_TIMEZONE tz;
+ FX_TIME time;
+ };
+ };
+ FX_DATETIME dt;
+ };
+ union {
+ struct {
+ int8_t tzHour;
+ uint8_t tzMinute;
};
-} FX_DATETIMEZONE, * FX_LPDATETIMEZONE;
-typedef FX_DATETIMEZONE const * FX_LPCDATETIMEZONE;
+ FX_TIMEZONE tz;
+ };
+} FX_DATETIMEZONE, *FX_LPDATETIMEZONE;
+typedef FX_DATETIMEZONE const* FX_LPCDATETIMEZONE;
#if _FX_OS_ != _FX_ANDROID_
#pragma pack(pop)
#endif
-class CFX_DateTime
-{
-public:
- CFX_DateTime() {}
- CFX_DateTime(const FX_DATETIME &dt)
- {
- m_DateTime = dt;
- }
- CFX_DateTime(const CFX_DateTime &dt)
- {
- m_DateTime = dt.m_DateTime;
- }
- virtual ~CFX_DateTime() {}
- operator FX_DATETIME * ()
- {
- return &m_DateTime;
- }
- operator FX_DATETIME const * () const
- {
- return &m_DateTime;
- }
- operator FX_DATETIME& ()
- {
- return m_DateTime;
- }
- operator const FX_DATETIME& () const
- {
- return m_DateTime;
- }
- CFX_DateTime& operator = (const CFX_DateTime &dt)
- {
- m_DateTime = dt.m_DateTime;
- return *this;
- }
- CFX_DateTime& operator = (const FX_DATETIME &dt)
- {
- m_DateTime = dt;
- return *this;
- }
- CFX_DateTime& operator += (const CFX_DateTime &dt)
- {
- FromUnitime(ToUnitime() + dt.ToUnitime());
- return *this;
- }
- CFX_DateTime& operator += (const FX_DATETIME &dt)
- {
- FromUnitime(ToUnitime() + ((const CFX_DateTime&)dt).ToUnitime());
- return *this;
- }
- CFX_DateTime& operator -= (const CFX_DateTime &dt)
- {
- FromUnitime(ToUnitime() - dt.ToUnitime());
- return *this;
- }
- CFX_DateTime& operator -= (const FX_DATETIME &dt)
- {
- FromUnitime(ToUnitime() - ((const CFX_DateTime&)dt).ToUnitime());
- return *this;
- }
- virtual FX_BOOL Set(int32_t year, uint8_t month, uint8_t day, uint8_t hour = 0, uint8_t minute = 0, uint8_t second = 0, FX_WORD millisecond = 0);
- virtual FX_BOOL FromUnitime(FX_UNITIME t);
- virtual FX_UNITIME ToUnitime() const;
- virtual int32_t GetYear() const;
- virtual uint8_t GetMonth() const;
- virtual uint8_t GetDay() const;
- virtual FX_WEEKDAY GetDayOfWeek() const;
- virtual FX_WORD GetDayOfYear() const;
- virtual int64_t GetDayOfAD() const;
- virtual uint8_t GetHour() const;
- virtual uint8_t GetMinute() const;
- virtual uint8_t GetSecond() const;
- virtual FX_WORD GetMillisecond() const;
- virtual FX_BOOL AddYears(int32_t iYears);
- virtual FX_BOOL AddMonths(int32_t iMonths);
- virtual FX_BOOL AddDays(int32_t iDays);
- virtual FX_BOOL AddHours(int32_t iHours);
- virtual FX_BOOL AddMinutes(int32_t iMinutes);
- virtual FX_BOOL AddSeconds(int32_t iSeconds);
- virtual FX_BOOL AddMilliseconds(int32_t iMilliseconds);
- friend CFX_DateTime operator + (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
- {
- CFX_DateTime dt;
- dt.FromUnitime(dt1.ToUnitime() + dt2.ToUnitime());
- return dt;
- }
- friend CFX_DateTime operator + (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
- {
- CFX_DateTime dt;
- dt.FromUnitime(dt1.ToUnitime() + ((const CFX_DateTime&)dt2).ToUnitime());
- return dt;
- }
- friend CFX_DateTime operator + (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
- {
- CFX_DateTime dt;
- dt.FromUnitime(((const CFX_DateTime&)dt1).ToUnitime() + dt2.ToUnitime());
- return dt;
- }
- friend CFX_DateTime operator - (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
- {
- CFX_DateTime dt;
- dt.FromUnitime(dt1.ToUnitime() - dt2.ToUnitime());
- return dt;
- }
- friend CFX_DateTime operator - (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
- {
- CFX_DateTime dt;
- dt.FromUnitime(dt1.ToUnitime() - ((const CFX_DateTime&)dt2).ToUnitime());
- return dt;
- }
- friend CFX_DateTime operator - (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
- {
- CFX_DateTime dt;
- dt.FromUnitime(((const CFX_DateTime&)dt1).ToUnitime() - dt2.ToUnitime());
- return dt;
- }
- friend FX_BOOL operator == (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
- {
- return FXSYS_memcmp((FX_LPCDATETIME)dt1, (FX_LPCDATETIME)dt2, sizeof(FX_DATETIME)) == 0;
- }
- friend FX_BOOL operator == (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
- {
- return FXSYS_memcmp((FX_LPCDATETIME)dt1, &dt2, sizeof(FX_DATETIME)) == 0;
- }
- friend FX_BOOL operator == (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
- {
- return FXSYS_memcmp(&dt1, (FX_LPCDATETIME)dt2, sizeof(FX_DATETIME)) == 0;
- }
- friend FX_BOOL operator != (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
- {
- return FXSYS_memcmp((FX_LPCDATETIME)dt1, (FX_LPCDATETIME)dt2, sizeof(FX_DATETIME)) != 0;
- }
- friend FX_BOOL operator != (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
- {
- return FXSYS_memcmp((FX_LPCDATETIME)dt1, &dt2, sizeof(FX_DATETIME)) != 0;
- }
- friend FX_BOOL operator != (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
- {
- return FXSYS_memcmp(&dt1, (FX_LPCDATETIME)dt2, sizeof(FX_DATETIME)) != 0;
- }
- friend FX_BOOL operator > (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
- {
- return dt1.ToUnitime() > dt2.ToUnitime();
- }
- friend FX_BOOL operator > (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
- {
- return dt1.ToUnitime() > ((const CFX_DateTime&)dt2).ToUnitime();
- }
- friend FX_BOOL operator > (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
- {
- return ((const CFX_DateTime&)dt1).ToUnitime() > dt2.ToUnitime();
- }
- friend FX_BOOL operator >= (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
- {
- return dt1.ToUnitime() >= dt2.ToUnitime();
- }
- friend FX_BOOL operator >= (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
- {
- return dt1.ToUnitime() >= ((const CFX_DateTime&)dt2).ToUnitime();
- }
- friend FX_BOOL operator >= (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
- {
- return ((const CFX_DateTime&)dt1).ToUnitime() >= dt2.ToUnitime();
- }
- friend FX_BOOL operator < (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
- {
- return dt1.ToUnitime() < dt2.ToUnitime();
- }
- friend FX_BOOL operator < (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
- {
- return dt1.ToUnitime() < ((const CFX_DateTime&)dt2).ToUnitime();
- }
- friend FX_BOOL operator < (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
- {
- return ((const CFX_DateTime&)dt1).ToUnitime() < dt2.ToUnitime();
- }
- friend FX_BOOL operator <= (const CFX_DateTime &dt1, const CFX_DateTime &dt2)
- {
- return dt1.ToUnitime() <= dt2.ToUnitime();
- }
- friend FX_BOOL operator <= (const CFX_DateTime &dt1, const FX_DATETIME &dt2)
- {
- return dt1.ToUnitime() <= ((const CFX_DateTime&)dt2).ToUnitime();
- }
- friend FX_BOOL operator <= (const FX_DATETIME &dt1, const CFX_DateTime &dt2)
- {
- return ((const CFX_DateTime&)dt1).ToUnitime() <= dt2.ToUnitime();
- }
-private:
- FX_DATETIME m_DateTime;
+class CFX_DateTime {
+ public:
+ CFX_DateTime() {}
+ CFX_DateTime(const FX_DATETIME& dt) { m_DateTime = dt; }
+ CFX_DateTime(const CFX_DateTime& dt) { m_DateTime = dt.m_DateTime; }
+ virtual ~CFX_DateTime() {}
+ operator FX_DATETIME*() { return &m_DateTime; }
+ operator FX_DATETIME const*() const { return &m_DateTime; }
+ operator FX_DATETIME&() { return m_DateTime; }
+ operator const FX_DATETIME&() const { return m_DateTime; }
+ CFX_DateTime& operator=(const CFX_DateTime& dt) {
+ m_DateTime = dt.m_DateTime;
+ return *this;
+ }
+ CFX_DateTime& operator=(const FX_DATETIME& dt) {
+ m_DateTime = dt;
+ return *this;
+ }
+ CFX_DateTime& operator+=(const CFX_DateTime& dt) {
+ FromUnitime(ToUnitime() + dt.ToUnitime());
+ return *this;
+ }
+ CFX_DateTime& operator+=(const FX_DATETIME& dt) {
+ FromUnitime(ToUnitime() + ((const CFX_DateTime&)dt).ToUnitime());
+ return *this;
+ }
+ CFX_DateTime& operator-=(const CFX_DateTime& dt) {
+ FromUnitime(ToUnitime() - dt.ToUnitime());
+ return *this;
+ }
+ CFX_DateTime& operator-=(const FX_DATETIME& dt) {
+ FromUnitime(ToUnitime() - ((const CFX_DateTime&)dt).ToUnitime());
+ return *this;
+ }
+ virtual FX_BOOL Set(int32_t year,
+ uint8_t month,
+ uint8_t day,
+ uint8_t hour = 0,
+ uint8_t minute = 0,
+ uint8_t second = 0,
+ FX_WORD millisecond = 0);
+ virtual FX_BOOL FromUnitime(FX_UNITIME t);
+ virtual FX_UNITIME ToUnitime() const;
+ virtual int32_t GetYear() const;
+ virtual uint8_t GetMonth() const;
+ virtual uint8_t GetDay() const;
+ virtual FX_WEEKDAY GetDayOfWeek() const;
+ virtual FX_WORD GetDayOfYear() const;
+ virtual int64_t GetDayOfAD() const;
+ virtual uint8_t GetHour() const;
+ virtual uint8_t GetMinute() const;
+ virtual uint8_t GetSecond() const;
+ virtual FX_WORD GetMillisecond() const;
+ virtual FX_BOOL AddYears(int32_t iYears);
+ virtual FX_BOOL AddMonths(int32_t iMonths);
+ virtual FX_BOOL AddDays(int32_t iDays);
+ virtual FX_BOOL AddHours(int32_t iHours);
+ virtual FX_BOOL AddMinutes(int32_t iMinutes);
+ virtual FX_BOOL AddSeconds(int32_t iSeconds);
+ virtual FX_BOOL AddMilliseconds(int32_t iMilliseconds);
+ friend CFX_DateTime operator+(const CFX_DateTime& dt1,
+ const CFX_DateTime& dt2) {
+ CFX_DateTime dt;
+ dt.FromUnitime(dt1.ToUnitime() + dt2.ToUnitime());
+ return dt;
+ }
+ friend CFX_DateTime operator+(const CFX_DateTime& dt1,
+ const FX_DATETIME& dt2) {
+ CFX_DateTime dt;
+ dt.FromUnitime(dt1.ToUnitime() + ((const CFX_DateTime&)dt2).ToUnitime());
+ return dt;
+ }
+ friend CFX_DateTime operator+(const FX_DATETIME& dt1,
+ const CFX_DateTime& dt2) {
+ CFX_DateTime dt;
+ dt.FromUnitime(((const CFX_DateTime&)dt1).ToUnitime() + dt2.ToUnitime());
+ return dt;
+ }
+ friend CFX_DateTime operator-(const CFX_DateTime& dt1,
+ const CFX_DateTime& dt2) {
+ CFX_DateTime dt;
+ dt.FromUnitime(dt1.ToUnitime() - dt2.ToUnitime());
+ return dt;
+ }
+ friend CFX_DateTime operator-(const CFX_DateTime& dt1,
+ const FX_DATETIME& dt2) {
+ CFX_DateTime dt;
+ dt.FromUnitime(dt1.ToUnitime() - ((const CFX_DateTime&)dt2).ToUnitime());
+ return dt;
+ }
+ friend CFX_DateTime operator-(const FX_DATETIME& dt1,
+ const CFX_DateTime& dt2) {
+ CFX_DateTime dt;
+ dt.FromUnitime(((const CFX_DateTime&)dt1).ToUnitime() - dt2.ToUnitime());
+ return dt;
+ }
+ friend FX_BOOL operator==(const CFX_DateTime& dt1, const CFX_DateTime& dt2) {
+ return FXSYS_memcmp((FX_LPCDATETIME)dt1, (FX_LPCDATETIME)dt2,
+ sizeof(FX_DATETIME)) == 0;
+ }
+ friend FX_BOOL operator==(const CFX_DateTime& dt1, const FX_DATETIME& dt2) {
+ return FXSYS_memcmp((FX_LPCDATETIME)dt1, &dt2, sizeof(FX_DATETIME)) == 0;
+ }
+ friend FX_BOOL operator==(const FX_DATETIME& dt1, const CFX_DateTime& dt2) {
+ return FXSYS_memcmp(&dt1, (FX_LPCDATETIME)dt2, sizeof(FX_DATETIME)) == 0;
+ }
+ friend FX_BOOL operator!=(const CFX_DateTime& dt1, const CFX_DateTime& dt2) {
+ return FXSYS_memcmp((FX_LPCDATETIME)dt1, (FX_LPCDATETIME)dt2,
+ sizeof(FX_DATETIME)) != 0;
+ }
+ friend FX_BOOL operator!=(const CFX_DateTime& dt1, const FX_DATETIME& dt2) {
+ return FXSYS_memcmp((FX_LPCDATETIME)dt1, &dt2, sizeof(FX_DATETIME)) != 0;
+ }
+ friend FX_BOOL operator!=(const FX_DATETIME& dt1, const CFX_DateTime& dt2) {
+ return FXSYS_memcmp(&dt1, (FX_LPCDATETIME)dt2, sizeof(FX_DATETIME)) != 0;
+ }
+ friend FX_BOOL operator>(const CFX_DateTime& dt1, const CFX_DateTime& dt2) {
+ return dt1.ToUnitime() > dt2.ToUnitime();
+ }
+ friend FX_BOOL operator>(const CFX_DateTime& dt1, const FX_DATETIME& dt2) {
+ return dt1.ToUnitime() > ((const CFX_DateTime&)dt2).ToUnitime();
+ }
+ friend FX_BOOL operator>(const FX_DATETIME& dt1, const CFX_DateTime& dt2) {
+ return ((const CFX_DateTime&)dt1).ToUnitime() > dt2.ToUnitime();
+ }
+ friend FX_BOOL operator>=(const CFX_DateTime& dt1, const CFX_DateTime& dt2) {
+ return dt1.ToUnitime() >= dt2.ToUnitime();
+ }
+ friend FX_BOOL operator>=(const CFX_DateTime& dt1, const FX_DATETIME& dt2) {
+ return dt1.ToUnitime() >= ((const CFX_DateTime&)dt2).ToUnitime();
+ }
+ friend FX_BOOL operator>=(const FX_DATETIME& dt1, const CFX_DateTime& dt2) {
+ return ((const CFX_DateTime&)dt1).ToUnitime() >= dt2.ToUnitime();
+ }
+ friend FX_BOOL operator<(const CFX_DateTime& dt1, const CFX_DateTime& dt2) {
+ return dt1.ToUnitime() < dt2.ToUnitime();
+ }
+ friend FX_BOOL operator<(const CFX_DateTime& dt1, const FX_DATETIME& dt2) {
+ return dt1.ToUnitime() < ((const CFX_DateTime&)dt2).ToUnitime();
+ }
+ friend FX_BOOL operator<(const FX_DATETIME& dt1, const CFX_DateTime& dt2) {
+ return ((const CFX_DateTime&)dt1).ToUnitime() < dt2.ToUnitime();
+ }
+ friend FX_BOOL operator<=(const CFX_DateTime& dt1, const CFX_DateTime& dt2) {
+ return dt1.ToUnitime() <= dt2.ToUnitime();
+ }
+ friend FX_BOOL operator<=(const CFX_DateTime& dt1, const FX_DATETIME& dt2) {
+ return dt1.ToUnitime() <= ((const CFX_DateTime&)dt2).ToUnitime();
+ }
+ friend FX_BOOL operator<=(const FX_DATETIME& dt1, const CFX_DateTime& dt2) {
+ return ((const CFX_DateTime&)dt1).ToUnitime() <= dt2.ToUnitime();
+ }
+
+ private:
+ FX_DATETIME m_DateTime;
};
#endif