Skip to content

Commit 0aa182c

Browse files
author
Robert Fancsik
authored
Date.prototype.setYear should invalidate cached tza (#4955)
This patch fixes #4939 and fixes #4940. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent 6efe14d commit 0aa182c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,9 @@ ecma_builtin_date_prototype_dispatch_set (uint16_t builtin_routine_id, /**< buil
472472
if (ecma_number_is_nan (converted_number[0]))
473473
{
474474
*date_value_p = converted_number[0];
475+
#if JERRY_ESNEXT
476+
date_object_p->header.u.cls.u1.date_flags &= (uint8_t) ~ECMA_DATE_TZA_SET;
477+
#endif /* JERRY_ESNEXT */
475478
return ecma_make_number_value (converted_number[0]);
476479
}
477480

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 date = new Date(1970, 0);
16+
date.setYear(-0);
17+
assert(date.getFullYear() === 1900)

0 commit comments

Comments
 (0)