Jacek Caban : jscript: Added Date.getTime() implementation.

Alexandre Julliard julliard at winehq.org
Tue Oct 14 08:29:55 CDT 2008


Module: wine
Branch: master
Commit: 122198a24f06894115e3e6ed4d0b2207f14981e6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=122198a24f06894115e3e6ed4d0b2207f14981e6

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Oct 13 16:28:09 2008 -0500

jscript: Added Date.getTime() implementation.

---

 dlls/jscript/date.c       |   15 +++++++++++++--
 dlls/jscript/tests/api.js |    6 ++++++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/dlls/jscript/date.c b/dlls/jscript/date.c
index 8716751..0dac085 100644
--- a/dlls/jscript/date.c
+++ b/dlls/jscript/date.c
@@ -168,11 +168,22 @@ static HRESULT Date_toLocaleTimeString(DispatchEx *dispex, LCID lcid, WORD flags
     return E_NOTIMPL;
 }
 
+/* ECMA-262 3rd Edition    15.9.5.9 */
 static HRESULT Date_getTime(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, date->time);
+    }
+    return S_OK;
 }
 
 static HRESULT Date_getFullYear(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index 58847fa..42dc080 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -449,4 +449,10 @@ ok(testFuncToString.toString() === "function testFuncToString(x,y) {\n    return
 ok("" + testFuncToString === "function testFuncToString(x,y) {\n    return x+y;\n}",
    "'' + testFuncToString = " + testFuncToString);
 
+var date = new Date();
+
+date = new Date(100);
+ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
+ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
+
 reportSuccess();




More information about the wine-cvs mailing list