Piotr Caban : jscript: Added Date_getUTCSeconds and Date_getSeconds implementation.
Alexandre Julliard
julliard at winehq.org
Tue Jun 16 09:09:37 CDT 2009
Module: wine
Branch: master
Commit: 3523a1f2bbb3e1a717a8d807af19d8bd16640d8c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3523a1f2bbb3e1a717a8d807af19d8bd16640d8c
Author: Piotr Caban <piotr.caban at gmail.com>
Date: Tue Jun 16 11:41:58 2009 +0200
jscript: Added Date_getUTCSeconds and Date_getSeconds implementation.
---
dlls/jscript/date.c | 46 +++++++++++++++++++++++++++++++++++++++++---
dlls/jscript/tests/api.js | 4 +++
2 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/dlls/jscript/date.c b/dlls/jscript/date.c
index 7a51c2c..1043a28 100644
--- a/dlls/jscript/date.c
+++ b/dlls/jscript/date.c
@@ -249,6 +249,20 @@ static inline DOUBLE min_from_time(DOUBLE time)
return ret;
}
+/* ECMA-262 3th Edition 15.9.1.10 */
+static inline DOUBLE sec_from_time(DOUBLE time)
+{
+ DOUBLE ret;
+
+ if(isnan(time))
+ return ret_nan();
+
+ ret = fmod(floor(time/1000), 60);
+ if(ret<0) ret += 60;
+
+ return ret;
+}
+
/* ECMA-262 3rd Edition 15.9.1.14 */
static inline DOUBLE time_clip(DOUBLE time)
{
@@ -582,18 +596,42 @@ static HRESULT Date_getUTCMinutes(DispatchEx *dispex, LCID lcid, WORD flags, DIS
return S_OK;
}
+/* ECMA-262 3th Edition 15.9.1.10 */
static HRESULT Date_getSeconds(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{
- FIXME("\n");
- return E_NOTIMPL;
+ TRACE("\n");
+
+ if(!is_class(dispex, JSCLASS_DATE)) {
+ FIXME("throw TypeError\n");
+ return E_FAIL;
+ }
+
+ if(retv) {
+ DateInstance *date = (DateInstance*)dispex;
+ DOUBLE time = date->time - date->bias*MS_PER_MINUTE;
+
+ num_set_val(retv, sec_from_time(time));
+ }
+ return S_OK;
}
+/* ECMA-262 3th Edition 15.9.1.10 */
static HRESULT Date_getUTCSeconds(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{
- FIXME("\n");
- return E_NOTIMPL;
+ TRACE("\n");
+
+ if(!is_class(dispex, JSCLASS_DATE)) {
+ FIXME("throw TypeError\n");
+ return E_FAIL;
+ }
+
+ if(retv) {
+ DateInstance *date = (DateInstance*)dispex;
+ num_set_val(retv, sec_from_time(date->time));
+ }
+ return S_OK;
}
static HRESULT Date_getMiliseconds(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index d946845..c17641d 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -952,6 +952,7 @@ ok(date.getUTCDate() === 1, "date.getUTCDate() = " + date.getUTCDate());
ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
+ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
date.setTime(60*24*60*60*1000);
ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
@@ -959,6 +960,7 @@ ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
+ok(date.getUTCSeconds() === 0, "date.getUTCSeconds() = " + date.getUTCSeconds());
date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 60*60*1000 + 2*60*1000 + 2*1000 + 640);
ok(date.getUTCFullYear() === 1974, "date.getUTCFullYear() = " + date.getUTCFullYear());
ok(date.getUTCMonth() === 1, "date.getUTCMonth() = " + date.getUTCMonth());
@@ -967,6 +969,7 @@ ok(date.getUTCDate() === 28, "date.getUTCDate() = " + date.getUTCDate());
ok(date.getUTCDay() === 4, "date.getUTCDay() = " + date.getUTCDay());
ok(date.getUTCHours() === 1, "date.getUTCHours() = " + date.getUTCHours());
ok(date.getUTCMinutes() === 2, "date.getUTCMinutes() = " + date.getUTCMinutes());
+ok(date.getUTCSeconds() === 2, "date.getUTCSeconds() = " + date.getUTCSeconds());
date.setTime(Infinity);
ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
@@ -974,6 +977,7 @@ ok(isNaN(date.getUTCDate()), "date.getUTCDate() is not NaN");
ok(isNaN(date.getUTCDay()), "date.getUTCDay() is not NaN");
ok(isNaN(date.getUTCHours()), "date.getUTCHours() is not NaN");
ok(isNaN(date.getUTCMinutes()), "date.getUTCMinutes() is not NaN");
+ok(isNaN(date.getUTCSeconds()), "date.getUTCSeconds() is not NaN");
ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
More information about the wine-cvs
mailing list