From ec2209da158750beeeaeaab5dd68e58424921c4a Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 16 Nov 2017 22:08:27 +0000 Subject: Convert CFX_DateTime::Now to be static 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 Reviewed-by: Tom Sepez --- core/fxcrt/cfx_datetime.cpp | 16 ++++++++-------- core/fxcrt/cfx_datetime.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'core/fxcrt') 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(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); + return CFX_DateTime(utLocal.wYear, static_cast(utLocal.wMonth), + static_cast(utLocal.wDay), + static_cast(utLocal.wHour), + static_cast(utLocal.wMinute), + static_cast(utLocal.wSecond), + static_cast(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; -- cgit v1.2.3