Skip to content

Commit 7038325

Browse files
authored
Fix result of Date getters when called on invalid date (#3879)
Fixes #3878. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
1 parent 585332f commit 7038325

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ ecma_builtin_date_prototype_dispatch_get (uint16_t builtin_routine_id, /**< buil
237237
{
238238
if (ecma_number_is_nan (date_num))
239239
{
240-
return ecma_make_magic_string_value (LIT_MAGIC_STRING_NAN);
240+
return ecma_make_nan_value ();
241241
}
242242

243243
switch (builtin_routine_id)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
var d = new Date();
16+
17+
var s = d.setHours();
18+
assert (typeof s === "number" && isNaN (s));
19+
20+
var g = d.getHours();
21+
assert (typeof g === "number" && isNaN (g));

0 commit comments

Comments
 (0)