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
3f289de8
Commit
3f289de8
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_getMonth and Date_getUTCMonth implementation.
parent
8427127b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
4 deletions
+91
-4
date.c
dlls/jscript/date.c
+86
-4
api.js
dlls/jscript/tests/api.js
+5
-0
No files found.
dlls/jscript/date.c
View file @
3f289de8
...
...
@@ -87,6 +87,27 @@ static const WCHAR setUTCFullYearW[] = {'s','e','t','U','T','C','F','u','l','l',
#define MS_PER_DAY 86400000
#define MS_PER_MINUTE 60000
/* ECMA-262 3th Edition 15.9.1.2 */
static
inline
DOUBLE
day
(
DOUBLE
time
)
{
return
floor
(
time
/
MS_PER_DAY
);
}
/* ECMA-262 3th Edition 15.9.1.3 */
static
inline
DOUBLE
days_in_year
(
DOUBLE
year
)
{
int
y
;
if
(
year
!=
(
int
)
year
)
return
ret_nan
();
y
=
year
;
if
(
y
%
4
!=
0
)
return
365
;
if
(
y
%
100
!=
0
)
return
366
;
if
(
y
%
400
!=
0
)
return
365
;
return
366
;
}
/* ECMA-262 3th Edition 15.9.1.3 */
static
inline
DOUBLE
day_from_year
(
DOUBLE
year
)
{
...
...
@@ -124,6 +145,43 @@ static inline DOUBLE year_from_time(DOUBLE time)
return
y
;
}
/* ECMA-262 3th Edition 15.9.1.3 */
static
inline
int
in_leap_year
(
DOUBLE
time
)
{
if
(
days_in_year
(
year_from_time
(
time
))
==
366
)
return
1
;
return
0
;
}
/* ECMA-262 3th Edition 15.9.1.4 */
static
inline
int
day_within_year
(
DOUBLE
time
)
{
return
day
(
time
)
-
day_from_year
(
year_from_time
(
time
));
}
/* ECMA-262 3th Edition 15.9.1.4 */
static
inline
DOUBLE
month_from_time
(
DOUBLE
time
)
{
int
ily
=
in_leap_year
(
time
);
int
dwy
=
day_within_year
(
time
);
if
(
isnan
(
time
))
return
ret_nan
();
if
(
0
<=
dwy
&&
dwy
<
31
)
return
0
;
if
(
dwy
<
59
+
ily
)
return
1
;
if
(
dwy
<
90
+
ily
)
return
2
;
if
(
dwy
<
120
+
ily
)
return
3
;
if
(
dwy
<
151
+
ily
)
return
4
;
if
(
dwy
<
181
+
ily
)
return
5
;
if
(
dwy
<
212
+
ily
)
return
6
;
if
(
dwy
<
243
+
ily
)
return
7
;
if
(
dwy
<
273
+
ily
)
return
8
;
if
(
dwy
<
304
+
ily
)
return
9
;
if
(
dwy
<
334
+
ily
)
return
10
;
return
11
;
}
/* ECMA-262 3rd Edition 15.9.1.14 */
static
inline
DOUBLE
time_clip
(
DOUBLE
time
)
{
...
...
@@ -267,18 +325,42 @@ static HRESULT Date_getUTCFullYear(DispatchEx *dispex, LCID lcid, WORD flags, DI
return
S_OK
;
}
/* ECMA-262 3th Edition 15.9.1.4 */
static
HRESULT
Date_getMonth
(
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
,
month_from_time
(
time
));
}
return
S_OK
;
}
/* ECMA-262 3th Edition 15.9.1.4 */
static
HRESULT
Date_getUTCMonth
(
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
,
month_from_time
(
date
->
time
));
}
return
S_OK
;
}
static
HRESULT
Date_getDate
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
...
...
dlls/jscript/tests/api.js
View file @
3f289de8
...
...
@@ -947,12 +947,17 @@ 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
());
ok
(
date
.
getUTCMonth
()
===
0
,
"date.getUTCMonth() = "
+
date
.
getUTCMonth
());
date
.
setTime
(
60
*
24
*
60
*
60
*
1000
);
ok
(
date
.
getUTCFullYear
()
===
1970
,
"date.getUTCFullYear() = "
+
date
.
getUTCFullYear
());
ok
(
date
.
getUTCMonth
()
===
2
,
"date.getUTCMonth() = "
+
date
.
getUTCMonth
());
date
.
setTime
(
59
*
24
*
60
*
60
*
1000
+
4
*
365
*
24
*
60
*
60
*
1000
);
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
());
date
.
setTime
(
Infinity
);
ok
(
isNaN
(
date
.
getUTCFullYear
()),
"date.getUTCFullYear() is not NaN"
);
ok
(
isNaN
(
date
.
getUTCMonth
()),
"date.getUTCMonth() 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
);
...
...
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