summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/JS_Value.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-25 15:36:11 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-25 19:51:03 +0000
commit4c50b8b2a2cc1b88e8df92dbee7048356ec0a6fb (patch)
treec9197f9a52f161603a889b3d2a5e5f614d89fd6e /fpdfsdk/javascript/JS_Value.cpp
parent636904b802b93b047918ce1000019edfa5da59ed (diff)
downloadpdfium-4c50b8b2a2cc1b88e8df92dbee7048356ec0a6fb.tar.xz
Remove methods from CJS_Date
This CL converts CJS_Date to a thin wrapper around a v8::Local<v8::Date>. Change-Id: I1510ae5ff7757677e4fe18deac4593cc75493c1b Reviewed-on: https://pdfium-review.googlesource.com/16810 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
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);