diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-11-16 22:08:27 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-16 22:08:27 +0000 |
commit | ec2209da158750beeeaeaab5dd68e58424921c4a (patch) | |
tree | 2bd86c2fd6f417d8022e13bafdb275823bf83e75 | |
parent | 1c4735aed9442a8e442214a23a3df94bd8fc99b5 (diff) | |
download | pdfium-ec2209da158750beeeaeaab5dd68e58424921c4a.tar.xz |
Convert CFX_DateTime::Now to be staticchromium/3272
This CL converts the CFX_DateTime::Now method to be a static and updates
the callers.
Change-Id: I26052c6194ed2d43bca5fee2542787ce166eda85
Reviewed-on: https://pdfium-review.googlesource.com/18670
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r-- | core/fxcrt/cfx_datetime.cpp | 16 | ||||
-rw-r--r-- | core/fxcrt/cfx_datetime.h | 4 | ||||
-rw-r--r-- | fpdfsdk/fpdfattachment.cpp | 3 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffnotify.cpp | 3 |
4 files changed, 12 insertions, 14 deletions
diff --git a/core/fxcrt/cfx_datetime.cpp b/core/fxcrt/cfx_datetime.cpp index 38dad0d6ac..04fa8a57ba 100644 --- a/core/fxcrt/cfx_datetime.cpp +++ b/core/fxcrt/cfx_datetime.cpp @@ -90,7 +90,8 @@ bool FX_IsLeapYear(int32_t iYear) { return ((iYear % 4) == 0 && (iYear % 100) != 0) || (iYear % 400) == 0; } -void CFX_DateTime::Now() { +// static +CFX_DateTime CFX_DateTime::Now() { FXUT_SYSTEMTIME utLocal; #if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_ ::GetLocalTime((LPSYSTEMTIME)&utLocal); @@ -110,13 +111,12 @@ void CFX_DateTime::Now() { utLocal.wMillisecond = curTime.tv_usec / 1000; #endif // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_ - year_ = utLocal.wYear; - month_ = static_cast<uint8_t>(utLocal.wMonth); - day_ = static_cast<uint8_t>(utLocal.wDay); - hour_ = static_cast<uint8_t>(utLocal.wHour); - minute_ = static_cast<uint8_t>(utLocal.wMinute); - second_ = static_cast<uint8_t>(utLocal.wSecond); - millisecond_ = static_cast<uint16_t>(utLocal.wMillisecond); + return CFX_DateTime(utLocal.wYear, static_cast<uint8_t>(utLocal.wMonth), + static_cast<uint8_t>(utLocal.wDay), + static_cast<uint8_t>(utLocal.wHour), + static_cast<uint8_t>(utLocal.wMinute), + static_cast<uint8_t>(utLocal.wSecond), + static_cast<uint16_t>(utLocal.wMillisecond)); } int32_t CFX_DateTime::GetDayOfWeek() const { diff --git a/core/fxcrt/cfx_datetime.h b/core/fxcrt/cfx_datetime.h index 28991103f5..910a847506 100644 --- a/core/fxcrt/cfx_datetime.h +++ b/core/fxcrt/cfx_datetime.h @@ -14,6 +14,8 @@ uint8_t FX_DaysInMonth(int32_t iYear, uint8_t iMonth); class CFX_DateTime { public: + static CFX_DateTime Now(); + CFX_DateTime() : year_(0), month_(0), @@ -37,8 +39,6 @@ class CFX_DateTime { second_(second), millisecond_(millisecond) {} - void Now(); - void Reset() { year_ = 0; month_ = 0; diff --git a/fpdfsdk/fpdfattachment.cpp b/fpdfsdk/fpdfattachment.cpp index 8b3c8fe20a..eb835343e3 100644 --- a/fpdfsdk/fpdfattachment.cpp +++ b/fpdfsdk/fpdfattachment.cpp @@ -230,8 +230,7 @@ FPDFAttachment_SetFile(FPDF_ATTACHMENT attachment, pParamsDict->SetNewFor<CPDF_Number>("Size", static_cast<int>(len)); // Set the creation date of the new attachment in the dictionary. - CFX_DateTime dateTime; - dateTime.Now(); + CFX_DateTime dateTime = CFX_DateTime::Now(); pParamsDict->SetNewFor<CPDF_String>( "CreationDate", ByteString::Format("D:%d%02d%02d%02d%02d%02d", dateTime.GetYear(), diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp index fb63556da9..068cf70591 100644 --- a/xfa/fxfa/cxfa_ffnotify.cpp +++ b/xfa/fxfa/cxfa_ffnotify.cpp @@ -284,8 +284,7 @@ void CXFA_FFNotify::OpenDropDownList(CXFA_FFWidget* hWidget) { } WideString CXFA_FFNotify::GetCurrentDateTime() { - CFX_DateTime dataTime; - dataTime.Now(); + CFX_DateTime dataTime = CFX_DateTime::Now(); return WideString::Format(L"%d%02d%02dT%02d%02d%02d", dataTime.GetYear(), dataTime.GetMonth(), dataTime.GetDay(), dataTime.GetHour(), dataTime.GetMinute(), |