summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/JS_Value.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/javascript/JS_Value.cpp')
-rw-r--r--fpdfsdk/javascript/JS_Value.cpp73
1 files changed, 4 insertions, 69 deletions
diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp
index 4ef194b8f2..1ef5599e9e 100644
--- a/fpdfsdk/javascript/JS_Value.cpp
+++ b/fpdfsdk/javascript/JS_Value.cpp
@@ -19,12 +19,6 @@
namespace {
-double
-MakeDate(int year, int mon, int day, int hour, int min, int sec, int ms) {
- return JS_MakeDate(JS_MakeDay(year, mon, day),
- JS_MakeTime(hour, min, sec, ms));
-}
-
double GetLocalTZA() {
if (!FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))
return 0;
@@ -172,10 +166,6 @@ int DateFromTime(double t) {
}
}
-double JS_LocalTime(double d) {
- return d + GetLocalTZA() + GetDaylightSavingTA(d);
-}
-
} // namespace
CJS_Return::CJS_Return(bool result) : is_error_(!result) {}
@@ -219,71 +209,12 @@ int CJS_Array::GetLength(CJS_Runtime* pRuntime) const {
return pRuntime->GetArrayLength(m_pArray);
}
-CJS_Date::CJS_Date() {}
-
CJS_Date::CJS_Date(v8::Local<v8::Date> pDate) : m_pDate(pDate) {}
-CJS_Date::CJS_Date(CJS_Runtime* pRuntime, double dMsecTime)
- : m_pDate(pRuntime->NewDate(dMsecTime)) {}
-
-CJS_Date::CJS_Date(CJS_Runtime* pRuntime,
- int year,
- int mon,
- int day,
- int hour,
- int min,
- int sec)
- : m_pDate(pRuntime->NewDate(MakeDate(year, mon, day, hour, min, sec, 0))) {}
-
CJS_Date::CJS_Date(const CJS_Date& other) = default;
CJS_Date::~CJS_Date() {}
-bool CJS_Date::IsValidDate(CJS_Runtime* pRuntime) const {
- return !m_pDate.IsEmpty() && !std::isnan(pRuntime->ToDouble(m_pDate));
-}
-
-int CJS_Date::GetYear(CJS_Runtime* pRuntime) const {
- if (!IsValidDate(pRuntime))
- return 0;
-
- return JS_GetYearFromTime(JS_LocalTime(pRuntime->ToDouble(m_pDate)));
-}
-
-int CJS_Date::GetMonth(CJS_Runtime* pRuntime) const {
- if (!IsValidDate(pRuntime))
- return 0;
- return JS_GetMonthFromTime(JS_LocalTime(pRuntime->ToDouble(m_pDate)));
-}
-
-int CJS_Date::GetDay(CJS_Runtime* pRuntime) const {
- if (!IsValidDate(pRuntime))
- return 0;
-
- return JS_GetDayFromTime(JS_LocalTime(pRuntime->ToDouble(m_pDate)));
-}
-
-int CJS_Date::GetHours(CJS_Runtime* pRuntime) const {
- if (!IsValidDate(pRuntime))
- return 0;
-
- return JS_GetHourFromTime(JS_LocalTime(pRuntime->ToDouble(m_pDate)));
-}
-
-int CJS_Date::GetMinutes(CJS_Runtime* pRuntime) const {
- if (!IsValidDate(pRuntime))
- return 0;
-
- return JS_GetMinFromTime(JS_LocalTime(pRuntime->ToDouble(m_pDate)));
-}
-
-int CJS_Date::GetSeconds(CJS_Runtime* pRuntime) const {
- if (!IsValidDate(pRuntime))
- return 0;
-
- return JS_GetSecFromTime(JS_LocalTime(pRuntime->ToDouble(m_pDate)));
-}
-
double JS_GetDateTime() {
if (!FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))
return 0;
@@ -321,6 +252,10 @@ int JS_GetSecFromTime(double dt) {
return (int)Mod(floor(dt / 1000), 60);
}
+double JS_LocalTime(double d) {
+ return d + GetLocalTZA() + GetDaylightSavingTA(d);
+}
+
double JS_DateParse(const WideString& str) {
v8::Isolate* pIsolate = v8::Isolate::GetCurrent();
v8::Isolate::Scope isolate_scope(pIsolate);