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/javascript/JS_Value.h" | 7 #include "fpdfsdk/javascript/JS_Value.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 | 771 |
772 int JS_GetMonthFromTime(double dt) { | 772 int JS_GetMonthFromTime(double dt) { |
773 return _MonthFromTime(dt); | 773 return _MonthFromTime(dt); |
774 } | 774 } |
775 | 775 |
776 int JS_GetDayFromTime(double dt) { | 776 int JS_GetDayFromTime(double dt) { |
777 return _DateFromTime(dt); | 777 return _DateFromTime(dt); |
778 } | 778 } |
779 | 779 |
780 int JS_GetHourFromTime(double dt) { | 780 int JS_GetHourFromTime(double dt) { |
781 return (int)_Mod(FXSYS_floor((double)(dt / (60 * 60 * 1000))), 24); | 781 return (int)_Mod(floor(dt / (60 * 60 * 1000)), 24); |
782 } | 782 } |
783 | 783 |
784 int JS_GetMinFromTime(double dt) { | 784 int JS_GetMinFromTime(double dt) { |
785 return (int)_Mod(FXSYS_floor((double)(dt / (60 * 1000))), 60); | 785 return (int)_Mod(floor(dt / (60 * 1000)), 60); |
786 } | 786 } |
787 | 787 |
788 int JS_GetSecFromTime(double dt) { | 788 int JS_GetSecFromTime(double dt) { |
789 return (int)_Mod(FXSYS_floor((double)(dt / 1000)), 60); | 789 return (int)_Mod(floor(dt / 1000), 60); |
790 } | 790 } |
791 | 791 |
792 double JS_DateParse(const wchar_t* str) { | 792 double JS_DateParse(const wchar_t* str) { |
793 v8::Isolate* pIsolate = v8::Isolate::GetCurrent(); | 793 v8::Isolate* pIsolate = v8::Isolate::GetCurrent(); |
794 v8::Isolate::Scope isolate_scope(pIsolate); | 794 v8::Isolate::Scope isolate_scope(pIsolate); |
795 v8::HandleScope scope(pIsolate); | 795 v8::HandleScope scope(pIsolate); |
796 | 796 |
797 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); | 797 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); |
798 | 798 |
799 // Use the built-in object method. | 799 // Use the built-in object method. |
(...skipping 13 matching lines...) Expand all Loading... |
813 v8::Local<v8::Function> funC = v8::Local<v8::Function>::Cast(v); | 813 v8::Local<v8::Function> funC = v8::Local<v8::Function>::Cast(v); |
814 | 814 |
815 const int argc = 1; | 815 const int argc = 1; |
816 v8::Local<v8::String> timeStr = FXJS_WSToJSString(pIsolate, str); | 816 v8::Local<v8::String> timeStr = FXJS_WSToJSString(pIsolate, str); |
817 v8::Local<v8::Value> argv[argc] = {timeStr}; | 817 v8::Local<v8::Value> argv[argc] = {timeStr}; |
818 v = funC->Call(context, context->Global(), argc, argv).ToLocalChecked(); | 818 v = funC->Call(context, context->Global(), argc, argv).ToLocalChecked(); |
819 if (v->IsNumber()) { | 819 if (v->IsNumber()) { |
820 double date = v->ToNumber(context).ToLocalChecked()->Value(); | 820 double date = v->ToNumber(context).ToLocalChecked()->Value(); |
821 if (!_isfinite(date)) | 821 if (!_isfinite(date)) |
822 return date; | 822 return date; |
823 return date + _getLocalTZA() + _getDaylightSavingTA(date); | 823 return JS_LocalTime(date); |
824 } | 824 } |
825 } | 825 } |
826 } | 826 } |
827 return 0; | 827 return 0; |
828 } | 828 } |
829 | 829 |
830 double JS_MakeDay(int nYear, int nMonth, int nDate) { | 830 double JS_MakeDay(int nYear, int nMonth, int nDate) { |
831 if (!_isfinite(nYear) || !_isfinite(nMonth) || !_isfinite(nDate)) | 831 if (!_isfinite(nYear) || !_isfinite(nMonth) || !_isfinite(nDate)) |
832 return GetNan(); | 832 return GetNan(); |
833 double y = _toInteger(nYear); | 833 double y = _toInteger(nYear); |
(...skipping 28 matching lines...) Expand all Loading... |
862 return GetNan(); | 862 return GetNan(); |
863 | 863 |
864 return day * 86400000 + time; | 864 return day * 86400000 + time; |
865 } | 865 } |
866 | 866 |
867 bool JS_PortIsNan(double d) { | 867 bool JS_PortIsNan(double d) { |
868 return d != d; | 868 return d != d; |
869 } | 869 } |
870 | 870 |
871 double JS_LocalTime(double d) { | 871 double JS_LocalTime(double d) { |
872 return JS_GetDateTime() + _getDaylightSavingTA(d); | 872 return d + _getLocalTZA() + _getDaylightSavingTA(d); |
873 } | 873 } |
874 | 874 |
875 std::vector<CJS_Value> JS_ExpandKeywordParams( | 875 std::vector<CJS_Value> JS_ExpandKeywordParams( |
876 CJS_Runtime* pRuntime, | 876 CJS_Runtime* pRuntime, |
877 const std::vector<CJS_Value>& originals, | 877 const std::vector<CJS_Value>& originals, |
878 size_t nKeywords, | 878 size_t nKeywords, |
879 ...) { | 879 ...) { |
880 ASSERT(nKeywords); | 880 ASSERT(nKeywords); |
881 | 881 |
882 std::vector<CJS_Value> result(nKeywords, CJS_Value(pRuntime)); | 882 std::vector<CJS_Value> result(nKeywords, CJS_Value(pRuntime)); |
(...skipping 13 matching lines...) Expand all Loading... |
896 for (int i = 0; i < nKeywords; ++i) { | 896 for (int i = 0; i < nKeywords; ++i) { |
897 const wchar_t* property = va_arg(ap, const wchar_t*); | 897 const wchar_t* property = va_arg(ap, const wchar_t*); |
898 v8::Local<v8::Value> v8Value = | 898 v8::Local<v8::Value> v8Value = |
899 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property); | 899 FXJS_GetObjectElement(pRuntime->GetIsolate(), pObj, property); |
900 if (!v8Value->IsUndefined()) | 900 if (!v8Value->IsUndefined()) |
901 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown); | 901 result[i] = CJS_Value(pRuntime, v8Value, CJS_Value::VT_unknown); |
902 } | 902 } |
903 va_end(ap); | 903 va_end(ap); |
904 return result; | 904 return result; |
905 } | 905 } |
OLD | NEW |