[builtins] Convert double to integer in Date.prototype.setDate
date in Makeday should be converted to integer. https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.12 Bug: v8:7475,chromium:846723 Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng Change-Id: I3aa725e7ce1822345502284aec919695c4ca084d Reviewed-on: https://chromium-review.googlesource.com/1080110 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#53516}
This commit is contained in:
parent
9461aa5619
commit
10cfe818bd
1
AUTHORS
1
AUTHORS
@ -42,6 +42,7 @@ Alexander Botero-Lowry <alexbl@FreeBSD.org>
|
||||
Alexander Karpinsky <homm86@gmail.com>
|
||||
Alexandre Vassalotti <avassalotti@gmail.com>
|
||||
Alexis Campailla <alexis@janeasystems.com>
|
||||
Amos Lim <eui-sang.lim@samsung.com>
|
||||
Andreas Anyuru <andreas.anyuru@gmail.com>
|
||||
Andrew Paprocki <andrew@ishiboo.com>
|
||||
Andrei Kashcha <anvaka@gmail.com>
|
||||
|
@ -47,6 +47,7 @@ double MakeDay(double year, double month, double date) {
|
||||
(kMinMonth <= month && month <= kMaxMonth) && std::isfinite(date)) {
|
||||
int y = FastD2I(year);
|
||||
int m = FastD2I(month);
|
||||
int dt = FastD2I(date);
|
||||
y += m / 12;
|
||||
m %= 12;
|
||||
if (m < 0) {
|
||||
@ -80,7 +81,7 @@ double MakeDay(double year, double month, double date) {
|
||||
182, 213, 244, 274, 305, 335};
|
||||
day_from_year += kDayFromMonth[m];
|
||||
}
|
||||
return static_cast<double>(day_from_year - 1) + date;
|
||||
return static_cast<double>(day_from_year - 1 + dt);
|
||||
}
|
||||
return std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
|
@ -155,6 +155,11 @@ assertDoesNotThrow("new Date(0x40000000, 0x40000000, 0x40000000," +
|
||||
assertDoesNotThrow("new Date(-0x40000001, -0x40000001, -0x40000001," +
|
||||
"-0x40000001, -0x40000001, -0x40000001, -0x40000001)")
|
||||
|
||||
// Test that date as double type is treated as integer type in MakeDay
|
||||
// so that the hour should't be changed.
|
||||
d = new Date(2018, 0);
|
||||
assertEquals(Date.parse(new Date(2018, 0, 11)), d.setDate(11.2));
|
||||
assertEquals(0, d.getHours());
|
||||
|
||||
// Modified test from WebKit
|
||||
// LayoutTests/fast/js/script-tests/date-utc-timeclip.js:
|
||||
|
@ -432,9 +432,6 @@
|
||||
'intl402/NumberFormat/prototype/format/format-fraction-digits': [FAIL],
|
||||
'intl402/NumberFormat/prototype/format/format-significant-digits': [FAIL],
|
||||
|
||||
# https://bugs.chromium.org/p/v8/issues/detail?id=7475
|
||||
'built-ins/Date/UTC/non-integer-values': [FAIL],
|
||||
|
||||
# https://bugs.chromium.org/p/v8/issues/detail?id=7480
|
||||
'intl402/Collator/unicode-ext-seq-in-private-tag': [FAIL],
|
||||
'intl402/Collator/unicode-ext-seq-with-attribute': [FAIL],
|
||||
|
Loading…
Reference in New Issue
Block a user