Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
8427127b
Commit
8427127b
authored
Jun 09, 2009
by
Piotr Caban
Committed by
Alexandre Julliard
Jun 10, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added Date_getFullYear and Date_getUTCFullYear implementation.
parent
abe5dee0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
4 deletions
+78
-4
date.c
dlls/jscript/date.c
+69
-4
api.js
dlls/jscript/tests/api.js
+9
-0
No files found.
dlls/jscript/date.c
View file @
8427127b
...
...
@@ -83,6 +83,47 @@ static const WCHAR setUTCMonthW[] = {'s','e','t','U','T','C','M','o','n','t','h'
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
};
/*ECMA-262 3th Edition 15.9.1.2 */
#define MS_PER_DAY 86400000
#define MS_PER_MINUTE 60000
/* ECMA-262 3th Edition 15.9.1.3 */
static
inline
DOUBLE
day_from_year
(
DOUBLE
year
)
{
int
y
;
if
(
year
!=
(
int
)
year
)
return
ret_nan
();
y
=
year
;
return
365
*
(
y
-
1970
)
+
floor
((
y
-
1969
)
/
4
)
-
floor
((
y
-
1901
)
/
100
)
+
floor
((
y
-
1601
)
/
400
);
}
/* ECMA-262 3th Edition 15.9.1.3 */
static
inline
DOUBLE
time_from_year
(
DOUBLE
year
)
{
return
MS_PER_DAY
*
day_from_year
(
year
);
}
/* ECMA-262 3th Edition 15.9.1.3 */
static
inline
DOUBLE
year_from_time
(
DOUBLE
time
)
{
int
y
;
if
(
isnan
(
time
))
return
ret_nan
();
y
=
1970
+
time
/
365
.
25
/
MS_PER_DAY
;
if
(
time_from_year
(
y
)
>
time
)
while
(
time_from_year
(
y
)
>
time
)
y
--
;
else
while
(
time_from_year
(
y
+
1
)
<=
time
)
y
++
;
return
y
;
}
/* ECMA-262 3rd Edition 15.9.1.14 */
static
inline
DOUBLE
time_clip
(
DOUBLE
time
)
{
...
...
@@ -188,18 +229,42 @@ static HRESULT Date_getTime(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
return
S_OK
;
}
/* ECMA-262 3th Edition 15.9.1.3 */
static
HRESULT
Date_getFullYear
(
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
,
year_from_time
(
time
));
}
return
S_OK
;
}
/* ECMA-262 3th Edition 15.9.1.3 */
static
HRESULT
Date_getUTCFullYear
(
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
,
year_from_time
(
date
->
time
));
}
return
S_OK
;
}
static
HRESULT
Date_getMonth
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
...
...
dlls/jscript/tests/api.js
View file @
8427127b
...
...
@@ -945,6 +945,15 @@ ok(date.setTime(123) === 123, "date.setTime(123) !== 123");
ok
(
date
.
setTime
(
"123"
,
NaN
)
===
123
,
"date.setTime(
\"
123
\"
) !== 123"
);
ok
(
isNaN
(
date
.
setTime
(
NaN
)),
"date.setTime(NaN) is not NaN"
);
ok
(
date
.
setTime
(
0
)
===
date
.
getTime
(),
"date.setTime(0) !== date.getTime()"
);
ok
(
date
.
getUTCFullYear
()
===
1970
,
"date.getUTCFullYear() = "
+
date
.
getUTCFullYear
());
date
.
setTime
(
60
*
24
*
60
*
60
*
1000
);
ok
(
date
.
getUTCFullYear
()
===
1970
,
"date.getUTCFullYear() = "
+
date
.
getUTCFullYear
());
date
.
setTime
(
59
*
24
*
60
*
60
*
1000
+
4
*
365
*
24
*
60
*
60
*
1000
);
ok
(
date
.
getUTCFullYear
()
===
1974
,
"date.getUTCFullYear() = "
+
date
.
getUTCFullYear
());
date
.
setTime
(
Infinity
);
ok
(
isNaN
(
date
.
getUTCFullYear
()),
"date.getUTCFullYear() 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
);
Math
.
PI
=
"test"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment