From 0cf642f763b1ab8cdb3c52db80cf38e380c82a19 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 29 Mar 2017 14:50:40 -0400 Subject: Rename CFX_Unitime to CFX_DateTime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The name Unitime did not give any indication of what the class contained. This Cl renames to DateTime to more accurately refect the class holds a date and time. Change-Id: I95f96224822f46a7da46ae39c71d2e23fc16f7d5 Reviewed-on: https://pdfium-review.googlesource.com/3255 Commit-Queue: dsinclair Reviewed-by: Nicolás Peña --- BUILD.gn | 4 +- xfa/fgas/localization/cfx_datetime.cpp | 129 +++++++++++++++++++++++++++++++ xfa/fgas/localization/cfx_datetime.h | 103 ++++++++++++++++++++++++ xfa/fgas/localization/cfx_formatstring.h | 2 +- xfa/fgas/localization/fgas_datetime.cpp | 129 ------------------------------- xfa/fgas/localization/fgas_datetime.h | 106 ------------------------- xfa/fgas/localization/fgas_locale.cpp | 19 ++--- xfa/fgas/localization/fgas_locale.h | 8 +- xfa/fwl/cfwl_monthcalendar.cpp | 2 +- xfa/fwl/cfwl_monthcalendar.h | 2 +- xfa/fxfa/app/xfa_ffnotify.cpp | 2 +- xfa/fxfa/app/xfa_fftextedit.cpp | 6 +- xfa/fxfa/fm2js/xfa_fm2jscontext.cpp | 8 +- xfa/fxfa/parser/cxfa_localemgr.h | 2 +- xfa/fxfa/parser/cxfa_localevalue.cpp | 42 +++++----- xfa/fxfa/parser/cxfa_localevalue.h | 17 ++-- xfa/fxfa/parser/cxfa_timezoneprovider.h | 2 +- 17 files changed, 290 insertions(+), 293 deletions(-) create mode 100644 xfa/fgas/localization/cfx_datetime.cpp create mode 100644 xfa/fgas/localization/cfx_datetime.h delete mode 100644 xfa/fgas/localization/fgas_datetime.cpp delete mode 100644 xfa/fgas/localization/fgas_datetime.h diff --git a/BUILD.gn b/BUILD.gn index 4bcc9868d4..2c44ec7e76 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1252,10 +1252,10 @@ if (pdf_enable_xfa) { "xfa/fgas/layout/fgas_rtfbreak.h", "xfa/fgas/layout/fgas_textbreak.cpp", "xfa/fgas/layout/fgas_textbreak.h", + "xfa/fgas/localization/cfx_datetime.cpp", + "xfa/fgas/localization/cfx_datetime.h", "xfa/fgas/localization/cfx_decimal.cpp", "xfa/fgas/localization/cfx_formatstring.h", - "xfa/fgas/localization/fgas_datetime.cpp", - "xfa/fgas/localization/fgas_datetime.h", "xfa/fgas/localization/fgas_locale.cpp", "xfa/fgas/localization/fgas_locale.h", "xfa/fwl/cfwl_app.cpp", diff --git a/xfa/fgas/localization/cfx_datetime.cpp b/xfa/fgas/localization/cfx_datetime.cpp new file mode 100644 index 0000000000..eb804eed7a --- /dev/null +++ b/xfa/fgas/localization/cfx_datetime.cpp @@ -0,0 +1,129 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "core/fxcrt/fx_system.h" +#include "xfa/fgas/localization/cfx_datetime.h" + +#if _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_ || \ + _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ +#include +#include +#endif + +namespace { + +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; + +int32_t DaysBeforeMonthInYear(int32_t iYear, uint8_t iMonth) { + ASSERT(iYear != 0); + ASSERT(iMonth >= 1 && iMonth <= 12); + + const int32_t* p = + FX_IsLeapYear(iYear) ? g_FXDaysBeforeLeapMonth : g_FXDaysBeforeMonth; + return p[iMonth - 1]; +} + +int32_t DaysInYear(int32_t iYear) { + ASSERT(iYear != 0); + return FX_IsLeapYear(iYear) ? g_FXDaysPerLeapYear : g_FXDaysPerYear; +} + +int64_t DateToDays(int32_t iYear, + uint8_t iMonth, + uint8_t iDay, + bool bIncludeThisDay) { + ASSERT(iYear != 0); + ASSERT(iMonth >= 1 && iMonth <= 12); + ASSERT(iDay >= 1 && iDay <= FX_DaysInMonth(iYear, iMonth)); + + int64_t iDays = DaysBeforeMonthInYear(iYear, iMonth); + iDays += iDay; + if (!bIncludeThisDay) + iDays--; + + if (iYear > 0) { + iYear--; + } else { + iDays -= DaysInYear(iYear); + iYear++; + } + return iDays + static_cast(iYear) * 365 + iYear / 4 - iYear / 100 + + iYear / 400; +} + +struct FXUT_SYSTEMTIME { + uint16_t wYear; + uint16_t wMonth; + uint16_t wDayOfWeek; + uint16_t wDay; + uint16_t wHour; + uint16_t wMinute; + uint16_t wSecond; + uint16_t wMillisecond; +}; + +} // namespace + +uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth) { + ASSERT(iYear != 0); + ASSERT(iMonth >= 1 && iMonth <= 12); + + const uint8_t* p = + FX_IsLeapYear(iYear) ? g_FXDaysPerLeapMonth : g_FXDaysPerMonth; + return p[iMonth - 1]; +} + +bool FX_IsLeapYear(int32_t iYear) { + ASSERT(iYear != 0); + return ((iYear % 4) == 0 && (iYear % 100) != 0) || (iYear % 400) == 0; +} + +void CFX_DateTime::Now() { + FXUT_SYSTEMTIME utLocal; +#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ + _FX_OS_ == _FX_WIN64_ + ::GetLocalTime((LPSYSTEMTIME)&utLocal); +#elif _FX_OS_ != _FX_EMBEDDED_ + timeval curTime; + gettimeofday(&curTime, nullptr); + + struct tm st; + localtime_r(&curTime.tv_sec, &st); + utLocal.wYear = st.tm_year + 1900; + utLocal.wMonth = st.tm_mon + 1; + utLocal.wDayOfWeek = st.tm_wday; + utLocal.wDay = st.tm_mday; + utLocal.wHour = st.tm_hour; + utLocal.wMinute = st.tm_min; + utLocal.wSecond = st.tm_sec; + utLocal.wMillisecond = curTime.tv_usec / 1000; +#endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ + // _FX_OS_ == _FX_WIN64_ + + year_ = utLocal.wYear; + month_ = static_cast(utLocal.wMonth); + day_ = static_cast(utLocal.wDay); + hour_ = static_cast(utLocal.wHour); + minute_ = static_cast(utLocal.wMinute); + second_ = static_cast(utLocal.wSecond); + millisecond_ = static_cast(utLocal.wMillisecond); +} + +int32_t CFX_DateTime::GetDayOfWeek() const { + int32_t v = static_cast(DateToDays(year_, month_, day_, true) % 7); + if (v < 0) + v += 7; + return v; +} diff --git a/xfa/fgas/localization/cfx_datetime.h b/xfa/fgas/localization/cfx_datetime.h new file mode 100644 index 0000000000..d7bfa8d53a --- /dev/null +++ b/xfa/fgas/localization/cfx_datetime.h @@ -0,0 +1,103 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FGAS_LOCALIZATION_CFX_DATETIME_H_ +#define XFA_FGAS_LOCALIZATION_CFX_DATETIME_H_ + +#include "core/fxcrt/fx_system.h" + +bool FX_IsLeapYear(int32_t iYear); +uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth); + +class CFX_DateTime { + public: + CFX_DateTime() + : year_(0), + month_(0), + day_(0), + hour_(0), + minute_(0), + second_(0), + millisecond_(0) {} + CFX_DateTime(int32_t year, + uint8_t month, + uint8_t day, + uint8_t hour, + uint8_t minute, + uint8_t second, + uint16_t millisecond) + : year_(year), + month_(month), + day_(day), + hour_(hour), + minute_(minute), + second_(second), + millisecond_(millisecond) {} + + void Now(); + + void Reset() { + year_ = 0; + month_ = 0; + day_ = 0; + hour_ = 0; + minute_ = 0; + second_ = 0; + millisecond_ = 0; + } + + bool IsSet() const { + return year_ != 0 || month_ != 0 || day_ != 0 || hour_ != 0 || + minute_ != 0 || second_ != 0 || millisecond_ != 0; + } + + void SetDate(int32_t year, uint8_t month, uint8_t day) { + year_ = year; + month_ = month; + day_ = day; + } + + void SetTime(uint8_t hour, + uint8_t minute, + uint8_t second, + uint16_t millisecond) { + hour_ = hour; + minute_ = minute; + second_ = second; + millisecond_ = millisecond; + } + + int32_t GetYear() const { return year_; } + uint8_t GetMonth() const { return month_; } + uint8_t GetDay() const { return day_; } + uint8_t GetHour() const { return hour_; } + uint8_t GetMinute() const { return minute_; } + uint8_t GetSecond() const { return second_; } + uint16_t GetMillisecond() const { return millisecond_; } + int32_t GetDayOfWeek() const; + + private: + int32_t year_; + uint8_t month_; + uint8_t day_; + uint8_t hour_; + uint8_t minute_; + uint8_t second_; + uint16_t millisecond_; +}; + +#if _FX_OS_ != _FX_ANDROID_ +#pragma pack(push, 1) +#endif +struct FX_TIMEZONE { + int8_t tzHour; + uint8_t tzMinute; +}; +#if _FX_OS_ != _FX_ANDROID_ +#pragma pack(pop) +#endif + +#endif // XFA_FGAS_LOCALIZATION_CFX_DATETIME_H_ diff --git a/xfa/fgas/localization/cfx_formatstring.h b/xfa/fgas/localization/cfx_formatstring.h index 39319964aa..5fd60aac97 100644 --- a/xfa/fgas/localization/cfx_formatstring.h +++ b/xfa/fgas/localization/cfx_formatstring.h @@ -30,7 +30,7 @@ class CFX_FormatString { bool ParseDateTime(const CFX_WideString& wsSrcDateTime, const CFX_WideString& wsPattern, FX_DATETIMETYPE eDateTimeType, - CFX_Unitime* dtValue); + CFX_DateTime* dtValue); bool ParseZero(const CFX_WideString& wsSrcText, const CFX_WideString& wsPattern); bool ParseNull(const CFX_WideString& wsSrcText, diff --git a/xfa/fgas/localization/fgas_datetime.cpp b/xfa/fgas/localization/fgas_datetime.cpp deleted file mode 100644 index 973fb3b5e3..0000000000 --- a/xfa/fgas/localization/fgas_datetime.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "core/fxcrt/fx_system.h" -#include "xfa/fgas/localization/fgas_datetime.h" - -#if _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_ || \ - _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ -#include -#include -#endif - -namespace { - -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; - -int32_t DaysBeforeMonthInYear(int32_t iYear, uint8_t iMonth) { - ASSERT(iYear != 0); - ASSERT(iMonth >= 1 && iMonth <= 12); - - const int32_t* p = - FX_IsLeapYear(iYear) ? g_FXDaysBeforeLeapMonth : g_FXDaysBeforeMonth; - return p[iMonth - 1]; -} - -int32_t DaysInYear(int32_t iYear) { - ASSERT(iYear != 0); - return FX_IsLeapYear(iYear) ? g_FXDaysPerLeapYear : g_FXDaysPerYear; -} - -int64_t DateToDays(int32_t iYear, - uint8_t iMonth, - uint8_t iDay, - bool bIncludeThisDay) { - ASSERT(iYear != 0); - ASSERT(iMonth >= 1 && iMonth <= 12); - ASSERT(iDay >= 1 && iDay <= FX_DaysInMonth(iYear, iMonth)); - - int64_t iDays = DaysBeforeMonthInYear(iYear, iMonth); - iDays += iDay; - if (!bIncludeThisDay) - iDays--; - - if (iYear > 0) { - iYear--; - } else { - iDays -= DaysInYear(iYear); - iYear++; - } - return iDays + static_cast(iYear) * 365 + iYear / 4 - iYear / 100 + - iYear / 400; -} - -struct FXUT_SYSTEMTIME { - uint16_t wYear; - uint16_t wMonth; - uint16_t wDayOfWeek; - uint16_t wDay; - uint16_t wHour; - uint16_t wMinute; - uint16_t wSecond; - uint16_t wMillisecond; -}; - -} // namespace - -uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth) { - ASSERT(iYear != 0); - ASSERT(iMonth >= 1 && iMonth <= 12); - - const uint8_t* p = - FX_IsLeapYear(iYear) ? g_FXDaysPerLeapMonth : g_FXDaysPerMonth; - return p[iMonth - 1]; -} - -bool FX_IsLeapYear(int32_t iYear) { - ASSERT(iYear != 0); - return ((iYear % 4) == 0 && (iYear % 100) != 0) || (iYear % 400) == 0; -} - -void CFX_Unitime::Now() { - FXUT_SYSTEMTIME utLocal; -#if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ - _FX_OS_ == _FX_WIN64_ - ::GetLocalTime((LPSYSTEMTIME)&utLocal); -#elif _FX_OS_ != _FX_EMBEDDED_ - timeval curTime; - gettimeofday(&curTime, nullptr); - - struct tm st; - localtime_r(&curTime.tv_sec, &st); - utLocal.wYear = st.tm_year + 1900; - utLocal.wMonth = st.tm_mon + 1; - utLocal.wDayOfWeek = st.tm_wday; - utLocal.wDay = st.tm_mday; - utLocal.wHour = st.tm_hour; - utLocal.wMinute = st.tm_min; - utLocal.wSecond = st.tm_sec; - utLocal.wMillisecond = curTime.tv_usec / 1000; -#endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ - // _FX_OS_ == _FX_WIN64_ - - year_ = utLocal.wYear; - month_ = static_cast(utLocal.wMonth); - day_ = static_cast(utLocal.wDay); - hour_ = static_cast(utLocal.wHour); - minute_ = static_cast(utLocal.wMinute); - second_ = static_cast(utLocal.wSecond); - millisecond_ = static_cast(utLocal.wMillisecond); -} - -int32_t CFX_Unitime::GetDayOfWeek() const { - int32_t v = static_cast(DateToDays(year_, month_, day_, true) % 7); - if (v < 0) - v += 7; - return v; -} diff --git a/xfa/fgas/localization/fgas_datetime.h b/xfa/fgas/localization/fgas_datetime.h deleted file mode 100644 index 9225dccaaa..0000000000 --- a/xfa/fgas/localization/fgas_datetime.h +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FGAS_LOCALIZATION_FGAS_DATETIME_H_ -#define XFA_FGAS_LOCALIZATION_FGAS_DATETIME_H_ - -#include "core/fxcrt/fx_system.h" - -class CFX_Unitime; -class CFX_DateTime; - -bool FX_IsLeapYear(int32_t iYear); -uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth); - -class CFX_Unitime { - public: - CFX_Unitime() - : year_(0), - month_(0), - day_(0), - hour_(0), - minute_(0), - second_(0), - millisecond_(0) {} - CFX_Unitime(int32_t year, - uint8_t month, - uint8_t day, - uint8_t hour, - uint8_t minute, - uint8_t second, - uint16_t millisecond) - : year_(year), - month_(month), - day_(day), - hour_(hour), - minute_(minute), - second_(second), - millisecond_(millisecond) {} - - void Now(); - - void Reset() { - year_ = 0; - month_ = 0; - day_ = 0; - hour_ = 0; - minute_ = 0; - second_ = 0; - millisecond_ = 0; - } - - bool IsSet() const { - return year_ != 0 || month_ != 0 || day_ != 0 || hour_ != 0 || - minute_ != 0 || second_ != 0 || millisecond_ != 0; - } - - void SetDate(int32_t year, uint8_t month, uint8_t day) { - year_ = year; - month_ = month; - day_ = day; - } - - void SetTime(uint8_t hour, - uint8_t minute, - uint8_t second, - uint16_t millisecond) { - hour_ = hour; - minute_ = minute; - second_ = second; - millisecond_ = millisecond; - } - - int32_t GetYear() const { return year_; } - uint8_t GetMonth() const { return month_; } - uint8_t GetDay() const { return day_; } - uint8_t GetHour() const { return hour_; } - uint8_t GetMinute() const { return minute_; } - uint8_t GetSecond() const { return second_; } - uint16_t GetMillisecond() const { return millisecond_; } - int32_t GetDayOfWeek() const; - - private: - int32_t year_; - uint8_t month_; - uint8_t day_; - uint8_t hour_; - uint8_t minute_; - uint8_t second_; - uint16_t millisecond_; -}; - -#if _FX_OS_ != _FX_ANDROID_ -#pragma pack(push, 1) -#endif -struct FX_TIMEZONE { - int8_t tzHour; - uint8_t tzMinute; -}; -#if _FX_OS_ != _FX_ANDROID_ -#pragma pack(pop) -#endif - -#endif // XFA_FGAS_LOCALIZATION_FGAS_DATETIME_H_ diff --git a/xfa/fgas/localization/fgas_locale.cpp b/xfa/fgas/localization/fgas_locale.cpp index 17aae595dc..4747aafcf5 100644 --- a/xfa/fgas/localization/fgas_locale.cpp +++ b/xfa/fgas/localization/fgas_locale.cpp @@ -205,7 +205,7 @@ bool GetNumericDotIndex(const CFX_WideString& wsNum, bool ParseLocaleDate(const CFX_WideString& wsDate, const CFX_WideString& wsDatePattern, IFX_Locale* pLocale, - CFX_Unitime* datetime, + CFX_DateTime* datetime, int32_t& cc) { int32_t year = 1900; int32_t month = 1; @@ -416,7 +416,7 @@ void ResolveZone(uint8_t& wHour, bool ParseLocaleTime(const CFX_WideString& wsTime, const CFX_WideString& wsTimePattern, IFX_Locale* pLocale, - CFX_Unitime* datetime, + CFX_DateTime* datetime, int32_t& cc) { uint8_t hour = 0; uint8_t minute = 0; @@ -669,7 +669,7 @@ uint16_t GetWeekOfYear(uint16_t year, uint16_t month, uint16_t day) { bool DateFormat(const CFX_WideString& wsDatePattern, IFX_Locale* pLocale, - const CFX_Unitime& datetime, + const CFX_DateTime& datetime, CFX_WideString& wsResult) { bool bRet = true; int32_t year = datetime.GetYear(); @@ -777,7 +777,7 @@ bool DateFormat(const CFX_WideString& wsDatePattern, bool TimeFormat(const CFX_WideString& wsTimePattern, IFX_Locale* pLocale, - const CFX_Unitime& datetime, + const CFX_DateTime& datetime, CFX_WideString& wsResult) { bool bGMT = false; bool bRet = true; @@ -902,7 +902,7 @@ bool TimeFormat(const CFX_WideString& wsTimePattern, return bRet; } -bool FormatDateTimeInternal(const CFX_Unitime& dt, +bool FormatDateTimeInternal(const CFX_DateTime& dt, const CFX_WideString& wsDatePattern, const CFX_WideString& wsTimePattern, bool bDateFirst, @@ -921,7 +921,8 @@ bool FormatDateTimeInternal(const CFX_Unitime& dt, } // namespace -bool FX_DateFromCanonical(const CFX_WideString& wsDate, CFX_Unitime* datetime) { +bool FX_DateFromCanonical(const CFX_WideString& wsDate, + CFX_DateTime* datetime) { int32_t year = 1900; int32_t month = 1; int32_t day = 1; @@ -999,7 +1000,7 @@ bool FX_DateFromCanonical(const CFX_WideString& wsDate, CFX_Unitime* datetime) { } bool FX_TimeFromCanonical(const CFX_WideStringC& wsTime, - CFX_Unitime* datetime, + CFX_DateTime* datetime, IFX_Locale* pLocale) { if (wsTime.GetLength() == 0) return false; @@ -2038,7 +2039,7 @@ FX_DATETIMETYPE CFX_FormatString::GetDateTimeFormat( bool CFX_FormatString::ParseDateTime(const CFX_WideString& wsSrcDateTime, const CFX_WideString& wsPattern, FX_DATETIMETYPE eDateTimeType, - CFX_Unitime* dtValue) { + CFX_DateTime* dtValue) { dtValue->Reset(); if (wsSrcDateTime.IsEmpty() || wsPattern.IsEmpty()) { @@ -2658,7 +2659,7 @@ bool CFX_FormatString::FormatDateTime(const CFX_WideString& wsSrcDateTime, if (eCategory == FX_DATETIMETYPE_Unknown) { return false; } - CFX_Unitime dt; + CFX_DateTime dt; int32_t iT = wsSrcDateTime.Find(L"T"); if (iT < 0) { if (eCategory == FX_DATETIMETYPE_Date && diff --git a/xfa/fgas/localization/fgas_locale.h b/xfa/fgas/localization/fgas_locale.h index 5d8ddc0b52..aecd4d62d4 100644 --- a/xfa/fgas/localization/fgas_locale.h +++ b/xfa/fgas/localization/fgas_locale.h @@ -10,9 +10,7 @@ #include #include "core/fxcrt/fx_xml.h" -#include "xfa/fgas/localization/fgas_datetime.h" - -class CFX_Unitime; +#include "xfa/fgas/localization/cfx_datetime.h" enum FX_LOCALENUMSYMBOL { FX_LOCALENUMSYMBOL_Decimal, @@ -73,9 +71,9 @@ class IFX_Locale { virtual CFX_WideString GetNumPattern(FX_LOCALENUMSUBCATEGORY eType) const = 0; }; -bool FX_DateFromCanonical(const CFX_WideString& wsDate, CFX_Unitime* datetime); +bool FX_DateFromCanonical(const CFX_WideString& wsDate, CFX_DateTime* datetime); bool FX_TimeFromCanonical(const CFX_WideStringC& wsTime, - CFX_Unitime* datetime, + CFX_DateTime* datetime, IFX_Locale* pLocale); class CFX_Decimal { public: diff --git a/xfa/fwl/cfwl_monthcalendar.cpp b/xfa/fwl/cfwl_monthcalendar.cpp index b167141505..a973e75410 100644 --- a/xfa/fwl/cfwl_monthcalendar.cpp +++ b/xfa/fwl/cfwl_monthcalendar.cpp @@ -571,7 +571,7 @@ void CFWL_MonthCalendar::ClearDateItem() { void CFWL_MonthCalendar::ResetDateItem() { int32_t iDays = FX_DaysInMonth(m_iCurYear, m_iCurMonth); int32_t iDayOfWeek = - CFX_Unitime(m_iCurYear, m_iCurMonth, 1, 0, 0, 0, 0).GetDayOfWeek(); + CFX_DateTime(m_iCurYear, m_iCurMonth, 1, 0, 0, 0, 0).GetDayOfWeek(); for (int32_t i = 0; i < iDays; i++) { if (iDayOfWeek >= 7) iDayOfWeek = 0; diff --git a/xfa/fwl/cfwl_monthcalendar.h b/xfa/fwl/cfwl_monthcalendar.h index 164e339fa0..4835320cdb 100644 --- a/xfa/fwl/cfwl_monthcalendar.h +++ b/xfa/fwl/cfwl_monthcalendar.h @@ -10,7 +10,7 @@ #include #include -#include "xfa/fgas/localization/fgas_datetime.h" +#include "xfa/fgas/localization/cfx_datetime.h" #include "xfa/fwl/cfwl_event.h" #include "xfa/fwl/cfwl_widget.h" #include "xfa/fwl/cfwl_widgetproperties.h" diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp index 56562c9403..d9ec99aba9 100644 --- a/xfa/fxfa/app/xfa_ffnotify.cpp +++ b/xfa/fxfa/app/xfa_ffnotify.cpp @@ -263,7 +263,7 @@ void CXFA_FFNotify::OpenDropDownList(CXFA_FFWidget* hWidget) { pDocView->UpdateDocView(); } CFX_WideString CXFA_FFNotify::GetCurrentDateTime() { - CFX_Unitime dataTime; + CFX_DateTime dataTime; dataTime.Now(); CFX_WideString wsDateTime; diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index e99fefbd73..2658758718 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -522,7 +522,7 @@ bool CXFA_FFDateTimeEdit::LoadWidget() { case XFA_Element::Date: { if (!wsText.IsEmpty()) { CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc); - CFX_Unitime date = lcValue.GetDate(); + CFX_DateTime date = lcValue.GetDate(); if (date.IsSet()) pWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); } @@ -618,7 +618,7 @@ bool CXFA_FFDateTimeEdit::UpdateFWLData() { ((CFWL_DateTimePicker*)m_pNormalWidget)->SetEditText(wsText); if (IsFocused() && !wsText.IsEmpty()) { CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc); - CFX_Unitime date = lcValue.GetDate(); + CFX_DateTime date = lcValue.GetDate(); if (lcValue.IsValid()) { if (date.IsSet()) { static_cast(m_pNormalWidget) @@ -647,7 +647,7 @@ void CXFA_FFDateTimeEdit::OnSelectChanged(CFWL_Widget* pWidget, CFX_WideString wsPicture; m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit); CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr()); - date.SetDate(CFX_Unitime(iYear, iMonth, iDay, 0, 0, 0, 0)); + date.SetDate(CFX_DateTime(iYear, iMonth, iDay, 0, 0, 0, 0)); CFX_WideString wsDate; date.FormatPatterns(wsDate, wsPicture, m_pDataAcc->GetLocal(), diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp index 5ec6215336..8879f2bfa7 100644 --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp @@ -1164,7 +1164,7 @@ void CXFA_FM2JSContext::IsoTime2Num(CFXJSE_Value* pThis, return; } - CFX_Unitime uniTime = timeValue.GetTime(); + CFX_DateTime uniTime = timeValue.GetTime(); int32_t hour = uniTime.GetHour(); int32_t min = uniTime.GetMinute(); int32_t second = uniTime.GetSecond(); @@ -1580,7 +1580,7 @@ void CXFA_FM2JSContext::Time2Num(CFXJSE_Value* pThis, return; } - CFX_Unitime uniTime = localeValue.GetTime(); + CFX_DateTime uniTime = localeValue.GetTime(); int32_t hour = uniTime.GetHour(); int32_t min = uniTime.GetMinute(); int32_t second = uniTime.GetSecond(); @@ -1944,7 +1944,7 @@ bool CXFA_FM2JSContext::Local2IsoDate(CFXJSE_Value* pThis, CXFA_LocaleValue widgetValue(XFA_VT_DATE, CFX_WideString::FromUTF8(szDate), wsFormat, pLocale, pMgr); - CFX_Unitime dt = widgetValue.GetDate(); + CFX_DateTime dt = widgetValue.GetDate(); strIsoDate.Format("%4d-%02d-%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay()); return true; } @@ -1982,7 +1982,7 @@ bool CXFA_FM2JSContext::Local2IsoTime(CFXJSE_Value* pThis, wsFormat = L"time{" + wsFormat + L"}"; CXFA_LocaleValue widgetValue(XFA_VT_TIME, CFX_WideString::FromUTF8(szTime), wsFormat, pLocale, pMgr); - CFX_Unitime utime = widgetValue.GetTime(); + CFX_DateTime utime = widgetValue.GetTime(); strIsoTime.Format("%02d:%02d:%02d.%03d", utime.GetHour(), utime.GetMinute(), utime.GetSecond(), utime.GetMillisecond()); return true; diff --git a/xfa/fxfa/parser/cxfa_localemgr.h b/xfa/fxfa/parser/cxfa_localemgr.h index b3b9635765..6d360112f0 100644 --- a/xfa/fxfa/parser/cxfa_localemgr.h +++ b/xfa/fxfa/parser/cxfa_localemgr.h @@ -10,7 +10,7 @@ #include #include -#include "xfa/fgas/localization/fgas_datetime.h" +#include "xfa/fgas/localization/cfx_datetime.h" #include "xfa/fgas/localization/fgas_locale.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp index 1fd7ac197c..e66e55330f 100644 --- a/xfa/fxfa/parser/cxfa_localevalue.cpp +++ b/xfa/fxfa/parser/cxfa_localevalue.cpp @@ -130,7 +130,7 @@ bool CXFA_LocaleValue::ValidateValue(const CFX_WideString& wsValue, } break; case FX_LOCALECATEGORY_Date: { - CFX_Unitime dt; + CFX_DateTime dt; bRet = ValidateCanonicalDate(wsValue, &dt); if (!bRet) { bRet = pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Date, @@ -143,7 +143,7 @@ bool CXFA_LocaleValue::ValidateValue(const CFX_WideString& wsValue, break; } case FX_LOCALECATEGORY_Time: { - CFX_Unitime dt; + CFX_DateTime dt; bRet = pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Time, &dt); if (!bRet) { @@ -153,7 +153,7 @@ bool CXFA_LocaleValue::ValidateValue(const CFX_WideString& wsValue, break; } case FX_LOCALECATEGORY_DateTime: { - CFX_Unitime dt; + CFX_DateTime dt; bRet = pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_DateTime, &dt); if (!bRet) { @@ -347,31 +347,31 @@ double CXFA_LocaleValue::GetDoubleNum() const { return 0; } -CFX_Unitime CXFA_LocaleValue::GetDate() const { +CFX_DateTime CXFA_LocaleValue::GetDate() const { if (m_bValid && m_dwType == XFA_VT_DATE) { - CFX_Unitime dt; + CFX_DateTime dt; FX_DateFromCanonical(m_wsValue, &dt); return dt; } - return CFX_Unitime(); + return CFX_DateTime(); } -CFX_Unitime CXFA_LocaleValue::GetTime() const { +CFX_DateTime CXFA_LocaleValue::GetTime() const { if (m_bValid && m_dwType == XFA_VT_TIME) { ASSERT(m_pLocaleMgr); - CFX_Unitime dt; + CFX_DateTime dt; FX_TimeFromCanonical(m_wsValue.AsStringC(), &dt, m_pLocaleMgr->GetDefLocale()); return dt; } - return CFX_Unitime(); + return CFX_DateTime(); } -CFX_Unitime CXFA_LocaleValue::GetDateTime() const { +CFX_DateTime CXFA_LocaleValue::GetDateTime() const { if (m_bValid && m_dwType == XFA_VT_DATETIME) { int32_t index = m_wsValue.Find('T'); - CFX_Unitime dt; + CFX_DateTime dt; FX_DateFromCanonical(m_wsValue.Left(index), &dt); ASSERT(m_pLocaleMgr); FX_TimeFromCanonical( @@ -379,7 +379,7 @@ CFX_Unitime CXFA_LocaleValue::GetDateTime() const { m_pLocaleMgr->GetDefLocale()); return dt; } - return CFX_Unitime(); + return CFX_DateTime(); } bool CXFA_LocaleValue::SetText(const CFX_WideString& wsText) { @@ -408,7 +408,7 @@ bool CXFA_LocaleValue::SetNum(const CFX_WideString& wsNum, return m_bValid = ParsePatternValue(wsNum, wsFormat, pLocale); } -bool CXFA_LocaleValue::SetDate(const CFX_Unitime& d) { +bool CXFA_LocaleValue::SetDate(const CFX_DateTime& d) { m_dwType = XFA_VT_DATE; m_wsValue.Format(L"%04d-%02d-%02d", d.GetYear(), d.GetMonth(), d.GetDay()); return true; @@ -421,7 +421,7 @@ bool CXFA_LocaleValue::SetDate(const CFX_WideString& wsDate, return m_bValid = ParsePatternValue(wsDate, wsFormat, pLocale); } -bool CXFA_LocaleValue::SetTime(const CFX_Unitime& t) { +bool CXFA_LocaleValue::SetTime(const CFX_DateTime& t) { m_dwType = XFA_VT_TIME; m_wsValue.Format(L"%02d:%02d:%02d", t.GetHour(), t.GetMinute(), t.GetSecond()); @@ -440,7 +440,7 @@ bool CXFA_LocaleValue::SetTime(const CFX_WideString& wsTime, return m_bValid = ParsePatternValue(wsTime, wsFormat, pLocale); } -bool CXFA_LocaleValue::SetDateTime(const CFX_Unitime& dt) { +bool CXFA_LocaleValue::SetDateTime(const CFX_DateTime& dt) { m_dwType = XFA_VT_DATETIME; m_wsValue.Format(L"%04d-%02d-%02dT%02d:%02d:%02d", dt.GetYear(), dt.GetMonth(), dt.GetDay(), dt.GetHour(), dt.GetMinute(), @@ -557,7 +557,7 @@ bool CXFA_LocaleValue::ValidateCanonicalValue(const CFX_WideString& wsValue, if (wsValue.IsEmpty()) { return true; } - CFX_Unitime dt; + CFX_DateTime dt; switch (dwVType) { case XFA_VT_DATE: { if (ValidateCanonicalDate(wsValue, &dt)) @@ -592,7 +592,7 @@ bool CXFA_LocaleValue::ValidateCanonicalValue(const CFX_WideString& wsValue, return true; } bool CXFA_LocaleValue::ValidateCanonicalDate(const CFX_WideString& wsDate, - CFX_Unitime* unDate) { + CFX_DateTime* unDate) { const uint16_t LastDay[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const uint16_t wCountY = 4, wCountM = 2, wCountD = 2; int nLen = wsDate.GetLength(); @@ -784,7 +784,7 @@ bool CXFA_LocaleValue::ValidateCanonicalDateTime( wsDate = wsDateTime.Left(nSplitIndex); wsTime = wsDateTime.Right(wsDateTime.GetLength() - nSplitIndex - 1); - CFX_Unitime dt; + CFX_DateTime dt; return ValidateCanonicalDate(wsDate, &dt) && ValidateCanonicalTime(wsTime); } @@ -828,7 +828,7 @@ bool CXFA_LocaleValue::ParsePatternValue(const CFX_WideString& wsValue, bRet = pFormat->ParseText(wsValue, wsFormat, m_wsValue); break; case FX_LOCALECATEGORY_Date: { - CFX_Unitime dt; + CFX_DateTime dt; bRet = ValidateCanonicalDate(wsValue, &dt); if (!bRet) { bRet = pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Date, @@ -839,7 +839,7 @@ bool CXFA_LocaleValue::ParsePatternValue(const CFX_WideString& wsValue, break; } case FX_LOCALECATEGORY_Time: { - CFX_Unitime dt; + CFX_DateTime dt; bRet = pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_Time, &dt); if (bRet) @@ -847,7 +847,7 @@ bool CXFA_LocaleValue::ParsePatternValue(const CFX_WideString& wsValue, break; } case FX_LOCALECATEGORY_DateTime: { - CFX_Unitime dt; + CFX_DateTime dt; bRet = pFormat->ParseDateTime(wsValue, wsFormat, FX_DATETIMETYPE_DateTime, &dt); if (bRet) diff --git a/xfa/fxfa/parser/cxfa_localevalue.h b/xfa/fxfa/parser/cxfa_localevalue.h index 75687b4281..cb30d37792 100644 --- a/xfa/fxfa/parser/cxfa_localevalue.h +++ b/xfa/fxfa/parser/cxfa_localevalue.h @@ -12,7 +12,7 @@ #include "xfa/fxfa/parser/cxfa_widgetdata.h" class IFX_Locale; -class CFX_Unitime; +class CFX_DateTime; class CXFA_LocaleMgr; #define XFA_VT_NULL 0 @@ -54,7 +54,8 @@ class CXFA_LocaleValue { IFX_Locale* pLocale, XFA_VALUEPICTURE eValueType) const; bool ValidateCanonicalValue(const CFX_WideString& wsValue, uint32_t dwVType); - bool ValidateCanonicalDate(const CFX_WideString& wsDate, CFX_Unitime* unDate); + bool ValidateCanonicalDate(const CFX_WideString& wsDate, + CFX_DateTime* unDate); bool ValidateCanonicalTime(const CFX_WideString& wsTime); bool ValidateCanonicalDateTime(const CFX_WideString& wsDateTime); void GetNumbericFormat(CFX_WideString& wsFormat, @@ -72,9 +73,9 @@ class CXFA_LocaleValue { CFX_WideString GetText() const; float GetNum() const; double GetDoubleNum() const; - CFX_Unitime GetDate() const; - CFX_Unitime GetTime() const; - CFX_Unitime GetDateTime() const; + CFX_DateTime GetDate() const; + CFX_DateTime GetTime() const; + CFX_DateTime GetDateTime() const; bool SetText(const CFX_WideString& wsText); bool SetText(const CFX_WideString& wsText, const CFX_WideString& wsFormat, @@ -83,15 +84,15 @@ class CXFA_LocaleValue { bool SetNum(const CFX_WideString& wsNum, const CFX_WideString& wsFormat, IFX_Locale* pLocale); - bool SetDate(const CFX_Unitime& d); + bool SetDate(const CFX_DateTime& d); bool SetDate(const CFX_WideString& wsDate, const CFX_WideString& wsFormat, IFX_Locale* pLocale); - bool SetTime(const CFX_Unitime& t); + bool SetTime(const CFX_DateTime& t); bool SetTime(const CFX_WideString& wsTime, const CFX_WideString& wsFormat, IFX_Locale* pLocale); - bool SetDateTime(const CFX_Unitime& dt); + bool SetDateTime(const CFX_DateTime& dt); bool SetDateTime(const CFX_WideString& wsDateTime, const CFX_WideString& wsFormat, IFX_Locale* pLocale); diff --git a/xfa/fxfa/parser/cxfa_timezoneprovider.h b/xfa/fxfa/parser/cxfa_timezoneprovider.h index 493da32288..eace151987 100644 --- a/xfa/fxfa/parser/cxfa_timezoneprovider.h +++ b/xfa/fxfa/parser/cxfa_timezoneprovider.h @@ -7,7 +7,7 @@ #ifndef XFA_FXFA_PARSER_CXFA_TIMEZONEPROVIDER_H_ #define XFA_FXFA_PARSER_CXFA_TIMEZONEPROVIDER_H_ -#include "xfa/fgas/localization/fgas_datetime.h" +#include "xfa/fgas/localization/cfx_datetime.h" class CXFA_TimeZoneProvider { public: -- cgit v1.2.3