js/src/tests/js1_5/Date/regress-301738-02.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 //-----------------------------------------------------------------------------
michael@0 7 var BUGNUMBER = 301738;
michael@0 8 var summary = 'Date parse compatibilty with MSIE';
michael@0 9 var actual = '';
michael@0 10 var expect = '';
michael@0 11
michael@0 12 printBugNumber(BUGNUMBER);
michael@0 13 printStatus (summary);
michael@0 14
michael@0 15 /*
michael@0 16 Case 2. The input string is of the form "f/m/l" where f, m and l are
michael@0 17 integers, e.g. 7/16/45.
michael@0 18 Adjust the mon, mday and year values to achieve 100% MSIE
michael@0 19 compatibility.
michael@0 20 a. If 0 <= f < 70, f/m/l is interpreted as month/day/year.
michael@0 21 i. If year < 100, it is the number of years after 1900
michael@0 22 ii. If year >= 100, it is the number of years after 0.
michael@0 23 b. If 70 <= f < 100
michael@0 24 i. If m < 70, f/m/l is interpreted as
michael@0 25 year/month/day where year is the number of years after
michael@0 26 1900.
michael@0 27 ii. If m >= 70, the date is invalid.
michael@0 28 c. If f >= 100
michael@0 29 i. If m < 70, f/m/l is interpreted as
michael@0 30 year/month/day where year is the number of years after 0.
michael@0 31 ii. If m >= 70, the date is invalid.
michael@0 32 */
michael@0 33
michael@0 34 var f;
michael@0 35 var m;
michael@0 36 var l;
michael@0 37
michael@0 38 function newDate(f, m, l)
michael@0 39 {
michael@0 40 return new Date(f + '/' + m + '/' + l);
michael@0 41 }
michael@0 42
michael@0 43 function newDesc(f, m, l)
michael@0 44 {
michael@0 45 return f + '/' + m + '/' + l;
michael@0 46 }
michael@0 47
michael@0 48 // 2.a.i
michael@0 49 f = 0;
michael@0 50 m = 0;
michael@0 51 l = 0;
michael@0 52
michael@0 53 expect = (new Date(l, f-1, m)).toDateString();
michael@0 54 actual = newDate(f, m, l).toDateString();
michael@0 55 reportCompare(expect, actual, newDesc(f, m, l));
michael@0 56
michael@0 57 f = 0;
michael@0 58 m = 0;
michael@0 59 l = 100;
michael@0 60
michael@0 61 expect = (new Date(l, f-1, m)).toDateString();
michael@0 62 actual = newDate(f, m, l).toDateString();
michael@0 63 reportCompare(expect, actual, newDesc(f, m, l));
michael@0 64
michael@0 65 // 2.a.ii
michael@0 66 f = 0;
michael@0 67 m = 24;
michael@0 68 l = 100;
michael@0 69
michael@0 70 expect = (new Date(l, f-1, m)).toDateString();
michael@0 71 actual = newDate(f, m, l).toDateString();
michael@0 72 reportCompare(expect, actual, newDesc(f, m, l));
michael@0 73
michael@0 74 f = 0;
michael@0 75 m = 24;
michael@0 76 l = 2100;
michael@0 77
michael@0 78 expect = (new Date(l, f-1, m)).toDateString();
michael@0 79 actual = newDate(f, m, l).toDateString();
michael@0 80 reportCompare(expect, actual, newDesc(f, m, l));
michael@0 81
michael@0 82
michael@0 83 // 2.b.i
michael@0 84 f = 70;
michael@0 85 m = 24;
michael@0 86 l = 100;
michael@0 87
michael@0 88 expect = (new Date(f, m-1, l)).toDateString();
michael@0 89 actual = newDate(f, m, l).toDateString();
michael@0 90 reportCompare(expect, actual, newDesc(f, m, l));
michael@0 91
michael@0 92 f = 99;
michael@0 93 m = 12;
michael@0 94 l = 1;
michael@0 95
michael@0 96 expect = (new Date(f, m-1, l)).toDateString();
michael@0 97 actual = newDate(f, m, l).toDateString();
michael@0 98 reportCompare(expect, actual, newDesc(f, m, l));
michael@0 99
michael@0 100 // 2.b.ii.
michael@0 101
michael@0 102 f = 99;
michael@0 103 m = 70;
michael@0 104 l = 1;
michael@0 105
michael@0 106 expect = true;
michael@0 107 actual = isNaN(newDate(f, m, l));
michael@0 108 reportCompare(expect, actual, newDesc(f, m, l) + ' is an invalid date');
michael@0 109
michael@0 110 // 2.c.i
michael@0 111
michael@0 112 f = 100;
michael@0 113 m = 12;
michael@0 114 l = 1;
michael@0 115
michael@0 116 expect = (new Date(f, m-1, l)).toDateString();
michael@0 117 actual = newDate(f, m, l).toDateString();
michael@0 118 reportCompare(expect, actual, newDesc(f, m, l));
michael@0 119
michael@0 120 // 2.c.ii
michael@0 121
michael@0 122 f = 100;
michael@0 123 m = 70;
michael@0 124 l = 1;
michael@0 125
michael@0 126 expect = true;
michael@0 127 actual = isNaN(newDate(f, m, l));
michael@0 128 reportCompare(expect, actual, newDesc(f, m, l) + ' is an invalid date');
michael@0 129
michael@0 130

mercurial