OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "fpdfsdk/src/javascript/JS_Value.h" | 7 #include "fpdfsdk/src/javascript/JS_Value.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 int _Day(double t) { | 671 int _Day(double t) { |
672 return (int)FXSYS_floor(t / 86400000); | 672 return (int)FXSYS_floor(t / 86400000); |
673 } | 673 } |
674 | 674 |
675 int _YearFromTime(double t) { | 675 int _YearFromTime(double t) { |
676 // estimate the time. | 676 // estimate the time. |
677 int y = 1970 + static_cast<int>(t / (365.2425 * 86400000)); | 677 int y = 1970 + static_cast<int>(t / (365.2425 * 86400000)); |
678 if (_TimeFromYear(y) <= t) { | 678 if (_TimeFromYear(y) <= t) { |
679 while (_TimeFromYear(y + 1) <= t) | 679 while (_TimeFromYear(y + 1) <= t) |
680 y++; | 680 y++; |
681 } else | 681 } else { |
682 while (_TimeFromYear(y) > t) | 682 while (_TimeFromYear(y) > t) |
683 y--; | 683 y--; |
| 684 } |
684 return y; | 685 return y; |
685 } | 686 } |
686 | 687 |
687 int _DayWithinYear(double t) { | 688 int _DayWithinYear(double t) { |
688 int year = _YearFromTime(t); | 689 int year = _YearFromTime(t); |
689 int day = _Day(t); | 690 int day = _Day(t); |
690 return day - _DayFromYear(year); | 691 return day - _DayFromYear(year); |
691 } | 692 } |
692 | 693 |
693 int _MonthFromTime(double t) { | 694 int _MonthFromTime(double t) { |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 for (int i = 0; i < nKeywords; ++i) { | 900 for (int i = 0; i < nKeywords; ++i) { |
900 const wchar_t* property = va_arg(ap, const wchar_t*); | 901 const wchar_t* property = va_arg(ap, const wchar_t*); |
901 v8::Local<v8::Value> v8Value = | 902 v8::Local<v8::Value> v8Value = |
902 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property); | 903 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property); |
903 if (!v8Value->IsUndefined()) | 904 if (!v8Value->IsUndefined()) |
904 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown); | 905 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown); |
905 } | 906 } |
906 va_end(ap); | 907 va_end(ap); |
907 return result; | 908 return result; |
908 } | 909 } |
OLD | NEW |