From 706e187ed8be44eb50bdf7024674930a4e10fa45 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 22 Oct 2018 19:34:53 +0000 Subject: Fix timezone inconsistency in document methods test. We do this by adding an override that forces GM time on everyone when run from the test harness. Generalize presubmit warnings so that the new function passes. De-duplicate lambda capture in place of static function. Change-Id: I15b34bea558baf1763476b36f0bca76614984107 Reviewed-on: https://pdfium-review.googlesource.com/c/44390 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- fxjs/cfxjse_formcalc_context.cpp | 2 +- fxjs/js_define.cpp | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'fxjs') diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp index f95ee831a7..d77453ef72 100644 --- a/fxjs/cfxjse_formcalc_context.cpp +++ b/fxjs/cfxjse_formcalc_context.cpp @@ -959,7 +959,7 @@ void GetLocalTimeZone(int32_t* pHour, int32_t* pMin, int32_t* pSec) { FXSYS_time(&now); struct tm* pGmt = gmtime(&now); - struct tm* pLocal = localtime(&now); + struct tm* pLocal = FXSYS_localtime(&now); *pHour = pLocal->tm_hour - pGmt->tm_hour; *pMin = pLocal->tm_min - pGmt->tm_min; *pSec = pLocal->tm_sec - pGmt->tm_sec; diff --git a/fxjs/js_define.cpp b/fxjs/js_define.cpp index 54bd8e1c3a..b4e0197b54 100644 --- a/fxjs/js_define.cpp +++ b/fxjs/js_define.cpp @@ -24,7 +24,7 @@ double GetLocalTZA() { return 0; time_t t = 0; FXSYS_time(&t); - localtime(&t); + FXSYS_localtime(&t); #if _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_ // In gcc 'timezone' is a global variable declared in time.h. In VC++, that // variable was removed in VC++ 2015, with _get_timezone replacing it. @@ -38,7 +38,7 @@ int GetDaylightSavingTA(double d) { if (!FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) return 0; time_t t = (time_t)(d / 1000); - struct tm* tmp = localtime(&t); + struct tm* tmp = FXSYS_localtime(&t); if (!tmp) return 0; if (tmp->tm_isdst > 0) @@ -175,12 +175,10 @@ void JSDestructor(v8::Local obj) { double JS_GetDateTime() { if (!FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) return 0; - time_t t = FXSYS_time(nullptr); - struct tm* pTm = localtime(&t); - - int year = pTm->tm_year + 1900; - double t1 = TimeFromYear(year); + time_t t = FXSYS_time(nullptr); + struct tm* pTm = FXSYS_localtime(&t); + double t1 = TimeFromYear(pTm->tm_year + 1900); return t1 + pTm->tm_yday * 86400000.0 + pTm->tm_hour * 3600000.0 + pTm->tm_min * 60000.0 + pTm->tm_sec * 1000.0; } -- cgit v1.2.3