overflow-make-day.js (1032B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-date.utc 5 description: Values specified to MakeDay exceed their calendar boundaries 6 info: | 7 [...] 8 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). 9 10 MakeDay (year, month, date) 11 12 [...] 13 5. Let ym be y + floor(m / 12). 14 [...] 15 7. Find a value t such that YearFromTime(t) is ym and MonthFromTime(t) is mn 16 and DateFromTime(t) is 1; but if this is not possible (because some 17 argument is out of range), return NaN. 18 8. Return Day(t) + dt - 1. 19 ---*/ 20 21 assert.sameValue(Date.UTC(2016, 12), 1483228800000, 'month: 12'); 22 assert.sameValue(Date.UTC(2016, 13), 1485907200000, 'month: 13'); 23 assert.sameValue(Date.UTC(2016, 144), 1830297600000, 'month: 144'); 24 25 assert.sameValue(Date.UTC(2016, 0, 33), 1454371200000, 'day greater than month'); 26 assert.sameValue(Date.UTC(2016, 2, -27), 1454371200000, 'day negative value'); 27 28 reportCompare(0, 0);