summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-10-22 19:34:53 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-22 19:34:53 +0000
commit706e187ed8be44eb50bdf7024674930a4e10fa45 (patch)
tree9157a2c483b35d8e2ac11f655c29322594ad8d0b /fxjs
parent2f62d36bfac781428f3896b443177e033be4c554 (diff)
downloadpdfium-706e187ed8be44eb50bdf7024674930a4e10fa45.tar.xz
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 <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cfxjse_formcalc_context.cpp2
-rw-r--r--fxjs/js_define.cpp12
2 files changed, 6 insertions, 8 deletions
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<v8::Object> 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;
}