Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(710)

Unified Diff: fpdfsdk/src/javascript/JS_Value.cpp

Issue 1546443002: Merge to XFA: Fix JS seconds since epoch to date conversions. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: XFA changes Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « BUILD.gn ('k') | fpdfsdk/src/javascript/public_methods_embeddertest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/javascript/JS_Value.cpp
diff --git a/fpdfsdk/src/javascript/JS_Value.cpp b/fpdfsdk/src/javascript/JS_Value.cpp
index ea7bfda57ad712bd81b710fbf18bcd4f6ccf724f..bd00adcf4966333b3dc1fd89543af48f81683fac 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;
}
« no previous file with comments | « BUILD.gn ('k') | fpdfsdk/src/javascript/public_methods_embeddertest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698