From 86a61dc374e8abe351df03a1aa6665013cc39345 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 25 Mar 2016 10:00:11 -0700 Subject: util.printd() replaces specified date with current date. Added test case. Several bugs going on here: JS_LocalTime() ignoring argument and returning current time and not factoring in the time zone adjustment. Use of FXSYS_floor() silently casts result to float, losing precision required to extract minutes and seconds. Pre-existing wcsftime escapes not stripped. BUG=pdfium:413 Review URL: https://codereview.chromium.org/1833053002 --- fpdfsdk/javascript/JS_Value.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'fpdfsdk/javascript/JS_Value.cpp') diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp index 1da1525d09..5e403a524b 100644 --- a/fpdfsdk/javascript/JS_Value.cpp +++ b/fpdfsdk/javascript/JS_Value.cpp @@ -778,15 +778,15 @@ int JS_GetDayFromTime(double dt) { } int JS_GetHourFromTime(double dt) { - return (int)_Mod(FXSYS_floor((double)(dt / (60 * 60 * 1000))), 24); + return (int)_Mod(floor(dt / (60 * 60 * 1000)), 24); } int JS_GetMinFromTime(double dt) { - return (int)_Mod(FXSYS_floor((double)(dt / (60 * 1000))), 60); + return (int)_Mod(floor(dt / (60 * 1000)), 60); } int JS_GetSecFromTime(double dt) { - return (int)_Mod(FXSYS_floor((double)(dt / 1000)), 60); + return (int)_Mod(floor(dt / 1000), 60); } double JS_DateParse(const wchar_t* str) { @@ -820,7 +820,7 @@ double JS_DateParse(const wchar_t* str) { double date = v->ToNumber(context).ToLocalChecked()->Value(); if (!_isfinite(date)) return date; - return date + _getLocalTZA() + _getDaylightSavingTA(date); + return JS_LocalTime(date); } } } @@ -869,7 +869,7 @@ bool JS_PortIsNan(double d) { } double JS_LocalTime(double d) { - return JS_GetDateTime() + _getDaylightSavingTA(d); + return d + _getLocalTZA() + _getDaylightSavingTA(d); } std::vector JS_ExpandKeywordParams( -- cgit v1.2.3