year-offset.js (1037B)
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: Conditional offset of provided `year` value 6 info: | 7 1. Let y be ? ToNumber(year). 8 [...] 9 8. If y is not NaN and 0 ≤ ToInteger(y) ≤ 99, let yr be 1900+ToInteger(y); 10 otherwise, let yr be y. 11 9. Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). 12 ---*/ 13 14 assert.sameValue(Date.UTC(-1, 0), -62198755200000, '-1 (no offset)'); 15 16 assert.sameValue(Date.UTC(0, 0), -2208988800000, '+0'); 17 assert.sameValue(Date.UTC(-0, 0), -2208988800000, '-0'); 18 assert.sameValue(Date.UTC(-0.999999, 0), -2208988800000, '-0.999999'); 19 20 assert.sameValue(Date.UTC(70, 0), 0, '70'); 21 assert.sameValue(Date.UTC(70, 0), 0, '70.999999'); 22 23 assert.sameValue(Date.UTC(99, 0), 915148800000, '99'); 24 assert.sameValue(Date.UTC(99.999999, 0), 915148800000, '99.999999'); 25 26 assert.sameValue(Date.UTC(100, 0), -59011459200000, '100 (no offset)'); 27 28 reportCompare(0, 0);