S15.9.2.1_A2.js (2688B)
1 // Copyright 2009 the Sputnik authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-date-year-month-date-hours-minutes-seconds-ms 6 info: | 7 All of the arguments are optional, any arguments supplied are 8 accepted but are completely ignored. A string is created and returned as 9 if by the expression (new Date()).toString() 10 es5id: 15.9.2.1_A2 11 description: Use various number arguments and various types of ones 12 ---*/ 13 14 function isEqual(d1, d2) { 15 if (d1 === d2) { 16 return true; 17 } else if (Math.abs(Date.parse(d1) - Date.parse(d2)) <= 1000) { 18 return true; 19 } else { 20 return false; 21 } 22 } 23 24 assert( 25 isEqual(Date(), (new Date()).toString()), 26 'isEqual(Date(), (new Date()).toString()) must return true' 27 ); 28 29 assert( 30 isEqual(Date(1), (new Date()).toString()), 31 'isEqual(Date(1), (new Date()).toString()) must return true' 32 ); 33 34 assert( 35 isEqual(Date(1970, 1), (new Date()).toString()), 36 'isEqual(Date(1970, 1), (new Date()).toString()) must return true' 37 ); 38 39 assert( 40 isEqual(Date(1970, 1, 1), (new Date()).toString()), 41 'isEqual(Date(1970, 1, 1), (new Date()).toString()) must return true' 42 ); 43 44 assert( 45 isEqual(Date(1970, 1, 1, 1), (new Date()).toString()), 46 'isEqual(Date(1970, 1, 1, 1), (new Date()).toString()) must return true' 47 ); 48 49 assert( 50 isEqual(Date(1970, 1, 1, 1), (new Date()).toString()), 51 'isEqual(Date(1970, 1, 1, 1), (new Date()).toString()) must return true' 52 ); 53 54 assert( 55 isEqual(Date(1970, 1, 1, 1, 0), (new Date()).toString()), 56 'isEqual(Date(1970, 1, 1, 1, 0), (new Date()).toString()) must return true' 57 ); 58 59 assert( 60 isEqual(Date(1970, 1, 1, 1, 0, 0), (new Date()).toString()), 61 'isEqual(Date(1970, 1, 1, 1, 0, 0), (new Date()).toString()) must return true' 62 ); 63 64 assert( 65 isEqual(Date(1970, 1, 1, 1, 0, 0, 0), (new Date()).toString()), 66 'isEqual(Date(1970, 1, 1, 1, 0, 0, 0), (new Date()).toString()) must return true' 67 ); 68 69 assert( 70 isEqual(Date(Number.NaN), (new Date()).toString()), 71 'isEqual(Date(Number.NaN), (new Date()).toString()) must return true' 72 ); 73 74 assert( 75 isEqual(Date(Number.POSITIVE_INFINITY), (new Date()).toString()), 76 'isEqual(Date(Number.POSITIVE_INFINITY), (new Date()).toString()) must return true' 77 ); 78 79 assert( 80 isEqual(Date(Number.NEGATIVE_INFINITY), (new Date()).toString()), 81 'isEqual(Date(Number.NEGATIVE_INFINITY), (new Date()).toString()) must return true' 82 ); 83 84 assert( 85 isEqual(Date(undefined), (new Date()).toString()), 86 'isEqual(Date(undefined), (new Date()).toString()) must return true' 87 ); 88 89 assert( 90 isEqual(Date(null), (new Date()).toString()), 91 'isEqual(Date(null), (new Date()).toString()) must return true' 92 ); 93 94 reportCompare(0, 0);