Piotr Caban : jscript: Added Date_getUTCMinutes and Date_getMinutes implementation.

Alexandre Julliard julliard at winehq.org
Tue Jun 16 09:09:37 CDT 2009


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

Author: Piotr Caban <piotr.caban at gmail.com>
Date:   Tue Jun 16 11:41:52 2009 +0200

jscript: Added Date_getUTCMinutes and Date_getMinutes implementation.

---

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

diff --git a/dlls/jscript/date.c b/dlls/jscript/date.c
index dad8dc4..7a51c2c 100644
--- a/dlls/jscript/date.c
+++ b/dlls/jscript/date.c
@@ -235,6 +235,20 @@ static inline DOUBLE hour_from_time(DOUBLE time)
     return ret;
 }
 
+/* ECMA-262 3th Edition    15.9.1.10 */
+static inline DOUBLE min_from_time(DOUBLE time)
+{
+    DOUBLE ret;
+
+    if(isnan(time))
+        return ret_nan();
+
+    ret = fmod(floor(time/MS_PER_MINUTE), 60);
+    if(ret<0) ret += 60;
+
+    return ret;
+}
+
 /* ECMA-262 3rd Edition    15.9.1.14 */
 static inline DOUBLE time_clip(DOUBLE time)
 {
@@ -530,18 +544,42 @@ static HRESULT Date_getUTCHours(DispatchEx *dispex, LCID lcid, WORD flags, DISPP
     return S_OK;
 }
 
+/* ECMA-262 3th Edition    15.9.1.10 */
 static HRESULT Date_getMinutes(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, min_from_time(time));
+    }
+    return S_OK;
 }
 
+/* ECMA-262 3th Edition    15.9.1.10 */
 static HRESULT Date_getUTCMinutes(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, min_from_time(date->time));
+    }
+    return S_OK;
 }
 
 static HRESULT Date_getSeconds(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index ceb314f..d946845 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -951,25 +951,29 @@ ok(date.getUTCMonth() === 0, "date.getUTCMonth() = " + date.getUTCMonth());
 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());
 date.setTime(60*24*60*60*1000);
 ok(date.getUTCFullYear() === 1970, "date.getUTCFullYear() = " + date.getUTCFullYear());
 ok(date.getUTCMonth() === 2, "date.getUTCMonth() = " + date.getUTCMonth());
 ok(date.getUTCDate() === 2, "date.getUTCDate() = " + date.getUTCDate());
 ok(date.getUTCDay() === 1, "date.getUTCDay() = " + date.getUTCDay());
 ok(date.getUTCHours() === 0, "date.getUTCHours() = " + date.getUTCHours());
-date.setTime(59*24*60*60*1000 + 4*365*24*60*60*1000 + 1000*60*60);
+ok(date.getUTCMinutes() === 0, "date.getUTCMinutes() = " + date.getUTCMinutes());
+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());
 ok(date.getUTCMonth(123) === 1, "date.getUTCMonth() = " + date.getUTCMonth());
 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());
 date.setTime(Infinity);
 ok(isNaN(date.getUTCFullYear()), "date.getUTCFullYear() is not NaN");
 ok(isNaN(date.getUTCMonth()), "date.getUTCMonth() is not NaN");
 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(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