summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/JS_Value.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-12-21 11:04:44 -0800
committerLei Zhang <thestig@chromium.org>2015-12-21 11:04:44 -0800
commit1ac47ebfc2d106e25c3e13062cae2132daa49348 (patch)
tree4bda2756a1b751f9ded450692a6349fe32803231 /fpdfsdk/src/javascript/JS_Value.cpp
parente13aa30ebc64800b7e208e338ec5d520de2d2ebd (diff)
downloadpdfium-1ac47ebfc2d106e25c3e13062cae2132daa49348.tar.xz
Merge to XFA: Fix JS seconds since epoch to date conversions.
BUG=515137,564736 TBR=ochang@chromium.org, tsepez@chromium.org Review URL: https://codereview.chromium.org/1533233002 . Review URL: https://codereview.chromium.org/1544493003 . (cherry picked from commit b426e3edde040089b70d1a223c83b90957aa571d) (cherry picked from commit bd35d484a4027775f19ff93e9143e0b270133d42) Review URL: https://codereview.chromium.org/1546443002 .
Diffstat (limited to 'fpdfsdk/src/javascript/JS_Value.cpp')
-rw-r--r--fpdfsdk/src/javascript/JS_Value.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/fpdfsdk/src/javascript/JS_Value.cpp b/fpdfsdk/src/javascript/JS_Value.cpp
index ea7bfda57a..bd00adcf49 100644
--- a/fpdfsdk/src/javascript/JS_Value.cpp
+++ b/fpdfsdk/src/javascript/JS_Value.cpp
@@ -649,7 +649,7 @@ int _DayFromYear(int y) {
}
double _TimeFromYear(int y) {
- return ((double)86400000) * _DayFromYear(y);
+ return 86400000.0 * _DayFromYear(y);
}
double _TimeFromYearMonth(int y, int m) {
@@ -669,12 +669,12 @@ int _Day(double t) {
int _YearFromTime(double t) {
// estimate the time.
- int y = 1970 + (int)(t / (365.0 * 86400000));
+ int y = 1970 + static_cast<int>(t / (365.2425 * 86400000));
if (_TimeFromYear(y) <= t) {
while (_TimeFromYear(y + 1) <= t)
y++;
} else
- while (_TimeFromYear(y - 1) > t)
+ while (_TimeFromYear(y) > t)
y--;
return y;
}