Piotr Caban : jscript: Added Date_getYear implementation.

Alexandre Julliard julliard at winehq.org
Tue Jul 14 10:37:26 CDT 2009


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

Author: Piotr Caban <piotr.caban at gmail.com>
Date:   Tue Jul 14 01:37:11 2009 +0200

jscript: Added Date_getYear implementation.

---

 dlls/jscript/date.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/dlls/jscript/date.c b/dlls/jscript/date.c
index 642c9ec..b65f03e 100644
--- a/dlls/jscript/date.c
+++ b/dlls/jscript/date.c
@@ -87,6 +87,7 @@ static const WCHAR setMonthW[] = {'s','e','t','M','o','n','t','h',0};
 static const WCHAR setUTCMonthW[] = {'s','e','t','U','T','C','M','o','n','t','h',0};
 static const WCHAR setFullYearW[] = {'s','e','t','F','u','l','l','Y','e','a','r',0};
 static const WCHAR setUTCFullYearW[] = {'s','e','t','U','T','C','F','u','l','l','Y','e','a','r',0};
+static const WCHAR getYearW[] = {'g','e','t','Y','e','a','r',0};
 
 static const WCHAR UTCW[] = {'U','T','C',0};
 static const WCHAR parseW[] = {'p','a','r','s','e',0};
@@ -2134,6 +2135,37 @@ static HRESULT Date_setUTCFullYear(DispatchEx *dispex, LCID lcid, WORD flags, DI
     return S_OK;
 }
 
+/* ECMA-262 3rd Edition    B2.4 */
+static HRESULT Date_getYear(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
+        VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
+{
+    DateInstance *date;
+    DOUBLE t, year;
+
+    TRACE("\n");
+
+    if(!is_class(dispex, JSCLASS_DATE)) {
+        FIXME("throw TypeError\n");
+        return E_FAIL;
+    }
+
+    date = (DateInstance*)dispex;
+    t = local_time(date->time, date);
+
+
+    if(isnan(t)) {
+        if(retv)
+            num_set_nan(retv);
+        return S_OK;
+    }
+
+    year = year_from_time(t);
+    if(retv)
+        num_set_val(retv, (1900<=year && year<2000)?year-1900:year);
+
+    return S_OK;
+}
+
 static HRESULT Date_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
         VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
 {
@@ -2160,6 +2192,7 @@ static const builtin_prop_t Date_props[] = {
     {getUTCMinutesW,         Date_getUTCMinutes,         PROPF_METHOD},
     {getUTCMonthW,           Date_getUTCMonth,           PROPF_METHOD},
     {getUTCSecondsW,         Date_getUTCSeconds,         PROPF_METHOD},
+    {getYearW,               Date_getYear,               PROPF_METHOD},
     {hasOwnPropertyW,        Date_hasOwnProperty,        PROPF_METHOD},
     {isPrototypeOfW,         Date_isPrototypeOf,         PROPF_METHOD},
     {propertyIsEnumerableW,  Date_propertyIsEnumerable,  PROPF_METHOD},




More information about the wine-cvs mailing list