Index: xfa/src/fgas/src/localization/fx_datetime.cpp |
diff --git a/xfa/src/fgas/src/localization/fx_datetime.cpp b/xfa/src/fgas/src/localization/fx_datetime.cpp |
index 7c2b3d3540800cdcf8253faad9755b2883aa82b1..9a1da457d9079b85e95be8189c370d84bb052ffb 100644 |
--- a/xfa/src/fgas/src/localization/fx_datetime.cpp |
+++ b/xfa/src/fgas/src/localization/fx_datetime.cpp |
@@ -5,56 +5,56 @@ |
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
#include "../fgas_base.h" |
-const FX_BYTE g_FXDaysPerMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; |
-const FX_BYTE g_FXDaysPerLeapMonth[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; |
-const FX_INT32 g_FXDaysBeforeMonth[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; |
-const FX_INT32 g_FXDaysBeforeLeapMonth[12] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}; |
-const FX_INT32 g_FXDaysPerYear = 365; |
-const FX_INT32 g_FXDaysPerLeapYear = 366; |
-const FX_INT32 g_FXDaysPer4Years = 1461; |
-const FX_INT32 g_FXDaysPer100Years = 36524; |
-const FX_INT32 g_FXDaysPer400Years = 146097; |
-const FX_INT64 g_FXMillisecondsPerSecond = 1000; |
-const FX_INT64 g_FXMillisecondsPerMinute = 60000; |
-const FX_INT64 g_FXMillisecondsPerHour = 3600000; |
-const FX_INT64 g_FXMillisecondsPerDay = 86400000; |
+const uint8_t g_FXDaysPerMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; |
+const uint8_t g_FXDaysPerLeapMonth[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; |
+const int32_t g_FXDaysBeforeMonth[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; |
+const int32_t g_FXDaysBeforeLeapMonth[12] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}; |
+const int32_t g_FXDaysPerYear = 365; |
+const int32_t g_FXDaysPerLeapYear = 366; |
+const int32_t g_FXDaysPer4Years = 1461; |
+const int32_t g_FXDaysPer100Years = 36524; |
+const int32_t g_FXDaysPer400Years = 146097; |
+const int64_t g_FXMillisecondsPerSecond = 1000; |
+const int64_t g_FXMillisecondsPerMinute = 60000; |
+const int64_t g_FXMillisecondsPerHour = 3600000; |
+const int64_t g_FXMillisecondsPerDay = 86400000; |
#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_ |
-const FX_INT64 g_FXMillisecondsPerYear = 0x0757B12C00; |
-const FX_INT64 g_FXMillisecondsPerLeapYear = 0x075CD78800; |
-const FX_INT64 g_FXMillisecondsPer4Years = 0x1D63EB0C00; |
-const FX_INT64 g_FXMillisecondsPer100Years = 0x02DEBCCDD000; |
-const FX_INT64 g_FXMillisecondsPer400Years = 0x0B7AF85D9C00; |
+const int64_t g_FXMillisecondsPerYear = 0x0757B12C00; |
+const int64_t g_FXMillisecondsPerLeapYear = 0x075CD78800; |
+const int64_t g_FXMillisecondsPer4Years = 0x1D63EB0C00; |
+const int64_t g_FXMillisecondsPer100Years = 0x02DEBCCDD000; |
+const int64_t g_FXMillisecondsPer400Years = 0x0B7AF85D9C00; |
#endif |
-FX_BOOL FX_IsLeapYear(FX_INT32 iYear) |
+FX_BOOL FX_IsLeapYear(int32_t iYear) |
{ |
FXSYS_assert(iYear != 0); |
return ((iYear % 4) == 0 && (iYear % 100) != 0) || (iYear % 400) == 0; |
} |
-FX_INT32 FX_DaysInYear(FX_INT32 iYear) |
+int32_t FX_DaysInYear(int32_t iYear) |
{ |
FXSYS_assert(iYear != 0); |
return FX_IsLeapYear(iYear) ? g_FXDaysPerLeapYear : g_FXDaysPerYear; |
} |
-FX_BYTE FX_DaysInMonth(FX_INT32 iYear, FX_BYTE iMonth) |
+uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth) |
{ |
FXSYS_assert(iYear != 0); |
FXSYS_assert(iMonth >= 1 && iMonth <= 12); |
- const FX_BYTE *p = FX_IsLeapYear(iYear) ? g_FXDaysPerLeapMonth : g_FXDaysPerMonth; |
+ const uint8_t *p = FX_IsLeapYear(iYear) ? g_FXDaysPerLeapMonth : g_FXDaysPerMonth; |
return p[iMonth - 1]; |
} |
-static FX_INT32 FX_DaysBeforeMonthInYear(FX_INT32 iYear, FX_BYTE iMonth) |
+static int32_t FX_DaysBeforeMonthInYear(int32_t iYear, uint8_t iMonth) |
{ |
FXSYS_assert(iYear != 0); |
FXSYS_assert(iMonth >= 1 && iMonth <= 12); |
- const FX_INT32 *p = FX_IsLeapYear(iYear) ? g_FXDaysBeforeLeapMonth : g_FXDaysBeforeMonth; |
+ const int32_t *p = FX_IsLeapYear(iYear) ? g_FXDaysBeforeLeapMonth : g_FXDaysBeforeMonth; |
return p[iMonth - 1]; |
} |
-static FX_INT64 FX_DateToDays(FX_INT32 iYear, FX_BYTE iMonth, FX_BYTE iDay, FX_BOOL bIncludeThisDay = FALSE) |
+static int64_t FX_DateToDays(int32_t iYear, uint8_t iMonth, uint8_t iDay, FX_BOOL bIncludeThisDay = FALSE) |
{ |
FXSYS_assert(iYear != 0); |
FXSYS_assert(iMonth >= 1 && iMonth <= 12); |
FXSYS_assert(iDay >= 1 && iDay <= FX_DaysInMonth(iYear, iMonth)); |
- FX_INT64 iDays = FX_DaysBeforeMonthInYear(iYear, iMonth); |
+ int64_t iDays = FX_DaysBeforeMonthInYear(iYear, iMonth); |
iDays += iDay; |
if (!bIncludeThisDay) { |
iDays --; |
@@ -65,9 +65,9 @@ static FX_INT64 FX_DateToDays(FX_INT32 iYear, FX_BYTE iMonth, FX_BYTE iDay, FX_B |
iDays -= FX_DaysInYear(iYear); |
iYear ++; |
} |
- return iDays + (FX_INT64)iYear * 365 + iYear / 4 - iYear / 100 + iYear / 400; |
+ return iDays + (int64_t)iYear * 365 + iYear / 4 - iYear / 100 + iYear / 400; |
} |
-static void FX_DaysToDate(FX_INT64 iDays, FX_INT32 &iYear, FX_BYTE &iMonth, FX_BYTE &iDay) |
+static void FX_DaysToDate(int64_t iDays, int32_t &iYear, uint8_t &iMonth, uint8_t &iDay) |
{ |
FX_BOOL bBC = iDays < 0; |
if (bBC) { |
@@ -77,7 +77,7 @@ static void FX_DaysToDate(FX_INT64 iDays, FX_INT32 &iYear, FX_BYTE &iMonth, FX_B |
iMonth = 1; |
iDay = 1; |
if (iDays >= g_FXDaysPer400Years) { |
- iYear += (FX_INT32)(iDays / g_FXDaysPer400Years * 400); |
+ iYear += (int32_t)(iDays / g_FXDaysPer400Years * 400); |
iDays %= g_FXDaysPer400Years; |
} |
if (iDays >= g_FXDaysPer100Years) { |
@@ -85,16 +85,16 @@ static void FX_DaysToDate(FX_INT64 iDays, FX_INT32 &iYear, FX_BYTE &iMonth, FX_B |
iYear += 300; |
iDays -= g_FXDaysPer100Years * 3; |
} else { |
- iYear += (FX_INT32)(iDays / g_FXDaysPer100Years * 100); |
+ iYear += (int32_t)(iDays / g_FXDaysPer100Years * 100); |
iDays %= g_FXDaysPer100Years; |
} |
} |
if (iDays >= g_FXDaysPer4Years) { |
- iYear += (FX_INT32)(iDays / g_FXDaysPer4Years * 4); |
+ iYear += (int32_t)(iDays / g_FXDaysPer4Years * 4); |
iDays %= g_FXDaysPer4Years; |
} |
while (TRUE) { |
- FX_INT32 iYearDays = FX_DaysInYear(iYear); |
+ int32_t iYearDays = FX_DaysInYear(iYear); |
if (iDays < iYearDays) { |
if (bBC) { |
iYear = -iYear; |
@@ -106,14 +106,14 @@ static void FX_DaysToDate(FX_INT64 iDays, FX_INT32 &iYear, FX_BYTE &iMonth, FX_B |
iDays -= iYearDays; |
} |
while (TRUE) { |
- FX_INT32 iMonthDays = FX_DaysInMonth(iYear, iMonth); |
+ int32_t iMonthDays = FX_DaysInMonth(iYear, iMonth); |
if (iDays < iMonthDays) { |
break; |
} |
iMonth ++; |
iDays -= iMonthDays; |
} |
- iDay += (FX_BYTE)iDays; |
+ iDay += (uint8_t)iDays; |
} |
#if _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_ || _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ |
#include <time.h> |
@@ -153,8 +153,8 @@ void CFX_Unitime::Now() |
utLocal.wSecond = st.tm_sec; |
utLocal.wMilliseconds = curTime.tv_usec / 1000; |
#endif |
- Set(utLocal.wYear, (FX_BYTE)utLocal.wMonth, (FX_BYTE)utLocal.wDay, |
- (FX_BYTE)utLocal.wHour, (FX_BYTE)utLocal.wMinute, (FX_BYTE)utLocal.wSecond, (FX_WORD)utLocal.wMilliseconds); |
+ Set(utLocal.wYear, (uint8_t)utLocal.wMonth, (uint8_t)utLocal.wDay, |
+ (uint8_t)utLocal.wHour, (uint8_t)utLocal.wMinute, (uint8_t)utLocal.wSecond, (FX_WORD)utLocal.wMilliseconds); |
} |
void CFX_Unitime::SetGMTime() |
{ |
@@ -180,16 +180,16 @@ void CFX_Unitime::SetGMTime() |
utLocal.wSecond = st.tm_sec; |
utLocal.wMilliseconds = curTime.tv_usec / 1000; |
#endif |
- Set(utLocal.wYear, (FX_BYTE)utLocal.wMonth, (FX_BYTE)utLocal.wDay, |
- (FX_BYTE)utLocal.wHour, (FX_BYTE)utLocal.wMinute, (FX_BYTE)utLocal.wSecond, (FX_WORD)utLocal.wMilliseconds); |
+ Set(utLocal.wYear, (uint8_t)utLocal.wMonth, (uint8_t)utLocal.wDay, |
+ (uint8_t)utLocal.wHour, (uint8_t)utLocal.wMinute, (uint8_t)utLocal.wSecond, (FX_WORD)utLocal.wMilliseconds); |
} |
-void CFX_Unitime::Set(FX_INT32 year, FX_BYTE month, FX_BYTE day, FX_BYTE hour, FX_BYTE minute, FX_BYTE second, FX_WORD millisecond) |
+void CFX_Unitime::Set(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, FX_WORD millisecond) |
{ |
FXSYS_assert(hour <= 23); |
FXSYS_assert(minute <= 59); |
FXSYS_assert(second <= 59); |
FXSYS_assert(millisecond <= 999); |
- m_iUnitime = (FX_INT64)hour * g_FXMillisecondsPerHour + (FX_INT64)minute * g_FXMillisecondsPerMinute + (FX_INT64)second * g_FXMillisecondsPerSecond + millisecond; |
+ m_iUnitime = (int64_t)hour * g_FXMillisecondsPerHour + (int64_t)minute * g_FXMillisecondsPerMinute + (int64_t)second * g_FXMillisecondsPerSecond + millisecond; |
if (year > 0) { |
m_iUnitime = m_iUnitime + FX_DateToDays(year, month, day, FALSE) * g_FXMillisecondsPerDay; |
} |
@@ -198,30 +198,30 @@ void CFX_Unitime::Set(FX_UNITIME t) |
{ |
m_iUnitime = t; |
} |
-FX_INT32 CFX_Unitime::GetYear() const |
+int32_t CFX_Unitime::GetYear() const |
{ |
- FX_INT32 iYear; |
- FX_BYTE iMonth, iDay; |
+ int32_t iYear; |
+ uint8_t iMonth, iDay; |
FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); |
return iYear; |
} |
-FX_BYTE CFX_Unitime::GetMonth() const |
+uint8_t CFX_Unitime::GetMonth() const |
{ |
- FX_INT32 iYear; |
- FX_BYTE iMonth, iDay; |
+ int32_t iYear; |
+ uint8_t iMonth, iDay; |
FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); |
return iMonth; |
} |
-FX_BYTE CFX_Unitime::GetDay() const |
+uint8_t CFX_Unitime::GetDay() const |
{ |
- FX_INT32 iYear; |
- FX_BYTE iMonth, iDay; |
+ int32_t iYear; |
+ uint8_t iMonth, iDay; |
FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); |
return iDay; |
} |
FX_WEEKDAY CFX_Unitime::GetDayOfWeek() const |
{ |
- FX_INT32 v = (FX_INT32)((m_iUnitime / g_FXMillisecondsPerDay + 1) % 7); |
+ int32_t v = (int32_t)((m_iUnitime / g_FXMillisecondsPerDay + 1) % 7); |
if (v < 0) { |
v += 7; |
} |
@@ -229,62 +229,62 @@ FX_WEEKDAY CFX_Unitime::GetDayOfWeek() const |
} |
FX_WORD CFX_Unitime::GetDayOfYear() const |
{ |
- FX_INT32 iYear; |
- FX_BYTE iMonth, iDay; |
+ int32_t iYear; |
+ uint8_t iMonth, iDay; |
FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); |
return FX_DaysBeforeMonthInYear(iYear, iMonth) + iDay; |
} |
-FX_INT64 CFX_Unitime::GetDayOfAD() const |
+int64_t CFX_Unitime::GetDayOfAD() const |
{ |
FX_BOOL bBC = m_iUnitime < 0; |
- FX_INT64 iDays = m_iUnitime / g_FXMillisecondsPerDay; |
+ int64_t iDays = m_iUnitime / g_FXMillisecondsPerDay; |
iDays += bBC ? -1 : 0; |
if (bBC && (m_iUnitime % g_FXMillisecondsPerDay) == 0) { |
iDays ++; |
} |
return iDays; |
} |
-FX_BYTE CFX_Unitime::GetHour() const |
+uint8_t CFX_Unitime::GetHour() const |
{ |
- FX_INT32 v = (FX_INT32)(m_iUnitime % g_FXMillisecondsPerDay); |
+ int32_t v = (int32_t)(m_iUnitime % g_FXMillisecondsPerDay); |
if (v < 0) { |
v += g_FXMillisecondsPerDay; |
} |
- return (FX_BYTE)(v / g_FXMillisecondsPerHour); |
+ return (uint8_t)(v / g_FXMillisecondsPerHour); |
} |
-FX_BYTE CFX_Unitime::GetMinute() const |
+uint8_t CFX_Unitime::GetMinute() const |
{ |
- FX_INT32 v = (FX_INT32)(m_iUnitime % g_FXMillisecondsPerHour); |
+ int32_t v = (int32_t)(m_iUnitime % g_FXMillisecondsPerHour); |
if (v < 0) { |
v += g_FXMillisecondsPerHour; |
} |
- return (FX_BYTE)(v / g_FXMillisecondsPerMinute); |
+ return (uint8_t)(v / g_FXMillisecondsPerMinute); |
} |
-FX_BYTE CFX_Unitime::GetSecond() const |
+uint8_t CFX_Unitime::GetSecond() const |
{ |
- FX_INT32 v = (FX_INT32)(m_iUnitime % g_FXMillisecondsPerMinute); |
+ int32_t v = (int32_t)(m_iUnitime % g_FXMillisecondsPerMinute); |
if (v < 0) { |
v += g_FXMillisecondsPerMinute; |
} |
- return (FX_BYTE)(v / g_FXMillisecondsPerSecond); |
+ return (uint8_t)(v / g_FXMillisecondsPerSecond); |
} |
FX_WORD CFX_Unitime::GetMillisecond() const |
{ |
- FX_INT32 v = (FX_INT32)(m_iUnitime % g_FXMillisecondsPerSecond); |
+ int32_t v = (int32_t)(m_iUnitime % g_FXMillisecondsPerSecond); |
if (v < 0) { |
v += g_FXMillisecondsPerSecond; |
} |
return (FX_WORD)v; |
} |
-FX_BOOL CFX_Unitime::AddYears(FX_INT32 iYears) |
+FX_BOOL CFX_Unitime::AddYears(int32_t iYears) |
{ |
FX_UNITIME ut = m_iUnitime; |
if (ut < 0) { |
ut = -ut; |
} |
FX_UNITIME r = ut % g_FXMillisecondsPerDay; |
- FX_INT32 iYear; |
- FX_BYTE iMonth, iDay; |
+ int32_t iYear; |
+ uint8_t iMonth, iDay; |
FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); |
iYear += iYears; |
if (iYear == 0) { |
@@ -294,7 +294,7 @@ FX_BOOL CFX_Unitime::AddYears(FX_INT32 iYears) |
m_iUnitime += (iYear < 0) ? -r : r; |
return TRUE; |
} |
-FX_BOOL CFX_Unitime::AddMonths(FX_INT32 iMonths) |
+FX_BOOL CFX_Unitime::AddMonths(int32_t iMonths) |
{ |
FX_BOOL b = iMonths > 0; |
FX_UNITIME ut = m_iUnitime; |
@@ -302,8 +302,8 @@ FX_BOOL CFX_Unitime::AddMonths(FX_INT32 iMonths) |
ut = -ut; |
} |
FX_UNITIME r = ut % g_FXMillisecondsPerDay; |
- FX_INT32 iYear; |
- FX_BYTE iMonth, iDay; |
+ int32_t iYear; |
+ uint8_t iMonth, iDay; |
FX_DaysToDate(GetDayOfAD(), iYear, iMonth, iDay); |
iMonths += iMonth; |
while (iMonths < 1) { |
@@ -315,36 +315,36 @@ FX_BOOL CFX_Unitime::AddMonths(FX_INT32 iMonths) |
if (iYear == 0) { |
iYear = b ? 1 : -1; |
} |
- m_iUnitime = FX_DateToDays(iYear, (FX_BYTE)iMonths, iDay, FALSE) * g_FXMillisecondsPerDay; |
+ m_iUnitime = FX_DateToDays(iYear, (uint8_t)iMonths, iDay, FALSE) * g_FXMillisecondsPerDay; |
m_iUnitime += (iYear < 0) ? -r : r; |
return TRUE; |
} |
-FX_BOOL CFX_Unitime::AddDays(FX_INT32 iDays) |
+FX_BOOL CFX_Unitime::AddDays(int32_t iDays) |
{ |
- m_iUnitime += (FX_INT64)iDays * g_FXMillisecondsPerDay; |
+ m_iUnitime += (int64_t)iDays * g_FXMillisecondsPerDay; |
return TRUE; |
} |
-FX_BOOL CFX_Unitime::AddHours(FX_INT32 iHours) |
+FX_BOOL CFX_Unitime::AddHours(int32_t iHours) |
{ |
- m_iUnitime += (FX_INT64)iHours * g_FXMillisecondsPerHour; |
+ m_iUnitime += (int64_t)iHours * g_FXMillisecondsPerHour; |
return TRUE; |
} |
-FX_BOOL CFX_Unitime::AddMinutes(FX_INT32 iMinutes) |
+FX_BOOL CFX_Unitime::AddMinutes(int32_t iMinutes) |
{ |
- m_iUnitime += (FX_INT64)iMinutes * g_FXMillisecondsPerMinute; |
+ m_iUnitime += (int64_t)iMinutes * g_FXMillisecondsPerMinute; |
return TRUE; |
} |
-FX_BOOL CFX_Unitime::AddSeconds(FX_INT32 iSeconds) |
+FX_BOOL CFX_Unitime::AddSeconds(int32_t iSeconds) |
{ |
- m_iUnitime += ((FX_INT64)iSeconds) * g_FXMillisecondsPerSecond; |
+ m_iUnitime += ((int64_t)iSeconds) * g_FXMillisecondsPerSecond; |
return TRUE; |
} |
-FX_BOOL CFX_Unitime::AddMilliseconds(FX_INT32 iMilliseconds) |
+FX_BOOL CFX_Unitime::AddMilliseconds(int32_t iMilliseconds) |
{ |
m_iUnitime += iMilliseconds; |
return TRUE; |
} |
-FX_BOOL CFX_DateTime::Set(FX_INT32 year, FX_BYTE month, FX_BYTE day, FX_BYTE hour, FX_BYTE minute, FX_BYTE second, FX_WORD millisecond) |
+FX_BOOL CFX_DateTime::Set(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, FX_WORD millisecond) |
{ |
ASSERT(year != 0); |
ASSERT(month >= 1 && month <= 12); |
@@ -374,25 +374,25 @@ FX_BOOL CFX_DateTime::FromUnitime(FX_UNITIME t) |
} |
FX_UNITIME CFX_DateTime::ToUnitime() const |
{ |
- FX_UNITIME v = (FX_INT64)m_DateTime.Date.sDate.day * g_FXMillisecondsPerHour + (FX_INT64)m_DateTime.Time.sTime.minute * g_FXMillisecondsPerMinute + (FX_INT64)m_DateTime.Time.sTime.second * g_FXMillisecondsPerSecond + m_DateTime.Time.sTime.millisecond; |
+ FX_UNITIME v = (int64_t)m_DateTime.Date.sDate.day * g_FXMillisecondsPerHour + (int64_t)m_DateTime.Time.sTime.minute * g_FXMillisecondsPerMinute + (int64_t)m_DateTime.Time.sTime.second * g_FXMillisecondsPerSecond + m_DateTime.Time.sTime.millisecond; |
v += FX_DateToDays(m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, m_DateTime.Date.sDate.day, FALSE) * g_FXMillisecondsPerDay; |
return v; |
} |
-FX_INT32 CFX_DateTime::GetYear() const |
+int32_t CFX_DateTime::GetYear() const |
{ |
return m_DateTime.Date.sDate.year; |
} |
-FX_BYTE CFX_DateTime::GetMonth() const |
+uint8_t CFX_DateTime::GetMonth() const |
{ |
return m_DateTime.Date.sDate.month; |
} |
-FX_BYTE CFX_DateTime::GetDay() const |
+uint8_t CFX_DateTime::GetDay() const |
{ |
return m_DateTime.Date.sDate.day; |
} |
FX_WEEKDAY CFX_DateTime::GetDayOfWeek() const |
{ |
- FX_INT32 v = (FX_INT32)(FX_DateToDays(m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, m_DateTime.Date.sDate.day, TRUE) % 7); |
+ int32_t v = (int32_t)(FX_DateToDays(m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, m_DateTime.Date.sDate.day, TRUE) % 7); |
if (v < 0) { |
v += 7; |
} |
@@ -402,19 +402,19 @@ FX_WORD CFX_DateTime::GetDayOfYear() const |
{ |
return FX_DaysBeforeMonthInYear(m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month) + m_DateTime.Date.sDate.day; |
} |
-FX_INT64 CFX_DateTime::GetDayOfAD() const |
+int64_t CFX_DateTime::GetDayOfAD() const |
{ |
return FX_DateToDays(m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, m_DateTime.Date.sDate.day, TRUE); |
} |
-FX_BYTE CFX_DateTime::GetHour() const |
+uint8_t CFX_DateTime::GetHour() const |
{ |
return m_DateTime.Date.sDate.day; |
} |
-FX_BYTE CFX_DateTime::GetMinute() const |
+uint8_t CFX_DateTime::GetMinute() const |
{ |
return m_DateTime.Time.sTime.minute; |
} |
-FX_BYTE CFX_DateTime::GetSecond() const |
+uint8_t CFX_DateTime::GetSecond() const |
{ |
return m_DateTime.Time.sTime.second; |
} |
@@ -422,12 +422,12 @@ FX_WORD CFX_DateTime::GetMillisecond() const |
{ |
return m_DateTime.Time.sTime.millisecond; |
} |
-FX_BOOL CFX_DateTime::AddYears(FX_INT32 iYears) |
+FX_BOOL CFX_DateTime::AddYears(int32_t iYears) |
{ |
if (iYears == 0) { |
return FALSE; |
} |
- FX_INT32 v = m_DateTime.Date.sDate.year + iYears; |
+ int32_t v = m_DateTime.Date.sDate.year + iYears; |
if (v >= 0 && m_DateTime.Date.sDate.year < 0) { |
v ++; |
} else if (v <= 0 && m_DateTime.Date.sDate.year > 0) { |
@@ -436,7 +436,7 @@ FX_BOOL CFX_DateTime::AddYears(FX_INT32 iYears) |
m_DateTime.Date.sDate.year = v; |
return TRUE; |
} |
-FX_BOOL CFX_DateTime::AddMonths(FX_INT32 iMonths) |
+FX_BOOL CFX_DateTime::AddMonths(int32_t iMonths) |
{ |
if (iMonths == 0) { |
return FALSE; |
@@ -460,16 +460,16 @@ FX_BOOL CFX_DateTime::AddMonths(FX_INT32 iMonths) |
if (m_DateTime.Date.sDate.year == 0) { |
m_DateTime.Date.sDate.year = b ? 1 : -1; |
} |
- m_DateTime.Date.sDate.month = (FX_BYTE)iMonths; |
+ m_DateTime.Date.sDate.month = (uint8_t)iMonths; |
return TRUE; |
} |
-FX_BOOL CFX_DateTime::AddDays(FX_INT32 iDays) |
+FX_BOOL CFX_DateTime::AddDays(int32_t iDays) |
{ |
if (iDays == 0) { |
return FALSE; |
} |
- FX_INT64 v1 = FX_DateToDays(m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, m_DateTime.Date.sDate.day, TRUE); |
- FX_INT64 v2 = v1 + iDays; |
+ int64_t v1 = FX_DateToDays(m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, m_DateTime.Date.sDate.day, TRUE); |
+ int64_t v2 = v1 + iDays; |
if (v2 <= 0 && v1 > 0) { |
v2 --; |
} else if (v2 >= 0 && v1 < 0) { |
@@ -478,64 +478,64 @@ FX_BOOL CFX_DateTime::AddDays(FX_INT32 iDays) |
FX_DaysToDate(v2, m_DateTime.Date.sDate.year, m_DateTime.Date.sDate.month, m_DateTime.Date.sDate.day); |
return TRUE; |
} |
-FX_BOOL CFX_DateTime::AddHours(FX_INT32 iHours) |
+FX_BOOL CFX_DateTime::AddHours(int32_t iHours) |
{ |
if (iHours == 0) { |
return FALSE; |
} |
iHours += m_DateTime.Date.sDate.day; |
- FX_INT32 iDays = iHours / 24; |
+ int32_t iDays = iHours / 24; |
iHours %= 24; |
if (iHours < 0) { |
iDays --, iHours += 24; |
} |
- m_DateTime.Date.sDate.day = (FX_BYTE)iHours; |
+ m_DateTime.Date.sDate.day = (uint8_t)iHours; |
if (iDays != 0) { |
AddDays(iDays); |
} |
return TRUE; |
} |
-FX_BOOL CFX_DateTime::AddMinutes(FX_INT32 iMinutes) |
+FX_BOOL CFX_DateTime::AddMinutes(int32_t iMinutes) |
{ |
if (iMinutes == 0) { |
return FALSE; |
} |
iMinutes += m_DateTime.Time.sTime.minute; |
- FX_INT32 iHours = iMinutes / 60; |
+ int32_t iHours = iMinutes / 60; |
iMinutes %= 60; |
if (iMinutes < 0) { |
iHours --, iMinutes += 60; |
} |
- m_DateTime.Time.sTime.minute = (FX_BYTE)iMinutes; |
+ m_DateTime.Time.sTime.minute = (uint8_t)iMinutes; |
if (iHours != 0) { |
AddHours(iHours); |
} |
return TRUE; |
} |
-FX_BOOL CFX_DateTime::AddSeconds(FX_INT32 iSeconds) |
+FX_BOOL CFX_DateTime::AddSeconds(int32_t iSeconds) |
{ |
if (iSeconds == 0) { |
return FALSE; |
} |
iSeconds += m_DateTime.Time.sTime.second; |
- FX_INT32 iMinutes = iSeconds / 60; |
+ int32_t iMinutes = iSeconds / 60; |
iSeconds %= 60; |
if (iSeconds < 0) { |
iMinutes --, iSeconds += 60; |
} |
- m_DateTime.Time.sTime.second = (FX_BYTE)iSeconds; |
+ m_DateTime.Time.sTime.second = (uint8_t)iSeconds; |
if (iMinutes != 0) { |
AddMinutes(iMinutes); |
} |
return TRUE; |
} |
-FX_BOOL CFX_DateTime::AddMilliseconds(FX_INT32 iMilliseconds) |
+FX_BOOL CFX_DateTime::AddMilliseconds(int32_t iMilliseconds) |
{ |
if (iMilliseconds == 0) { |
return FALSE; |
} |
iMilliseconds += m_DateTime.Time.sTime.millisecond; |
- FX_INT32 iSeconds = (FX_INT32)(iMilliseconds / g_FXMillisecondsPerSecond); |
+ int32_t iSeconds = (int32_t)(iMilliseconds / g_FXMillisecondsPerSecond); |
iMilliseconds %= g_FXMillisecondsPerSecond; |
if (iMilliseconds < 0) { |
iSeconds --, iMilliseconds += g_FXMillisecondsPerSecond; |