• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
5 *
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
10 *
11 * The Original Code is Mozilla Communicator client code, released March
12 * 31, 1998.
13 *
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
17 * Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 */
22/**
23    File Name:          15.9.1.1-2.js
24    ECMA Section:       15.9.1.1 Time Range
25     Description:
26                            - leap seconds are ignored
27                            - assume 86400000 ms / day
28                            - numbers range fom +/- 9,007,199,254,740,991
29                            - ms precision for any instant that is within
30                              approximately +/-285,616 years from 1 jan 1970
31                              UTC
32                            - range of times supported is -100,000,000 days
33                              to 100,000,000 days from 1 jan 1970 12:00 am
34                            - time supported is 8.64e5*10e8 milliseconds from
35                              1 jan 1970 UTC  (+/-273972.6027397 years)
36    Author:             christine@netscape.com
37    Date:               9 july 1997
38*/
39
40function test() {
41
42    writeHeaderToLog("15.8.1.1 Time Range");
43
44    for (       M_SECS = 0, CURRENT_YEAR = 1970;
45                M_SECS > -8640000000000000;
46                tc++,   M_SECS -= FOUR_HUNDRED_YEARS, CURRENT_YEAR -= 400 ) {
47
48        testcases[tc] = new TestCase( SECTION, "new Date("+M_SECS+")", CURRENT_YEAR, (new Date( M_SECS )).getUTCFullYear() );
49
50        testcases[tc].passed =  writeTestCaseResult(
51                                testcases[tc].expect,
52                                testcases[tc].actual,
53                                testcases[tc].description + " = " +
54                                testcases[tc].actual );
55
56        if ( ! testcases[tc].passed ) {
57            testcases[tc].reason = "wrong year value";
58        }
59    }
60
61    stopTest();
62
63    return ( testcases );
64}
65    //  every one hundred years contains:
66    //    24 years with 366 days
67    //
68    //  every four hundred years contains:
69    //    97 years with 366 days
70    //   303 years with 365 days
71    //
72    //   86400000*366*97  =    3067372800000
73    //  +86400000*365*303 =  + 9555408000000
74    //                    =    1.26227808e+13
75
76    var FOUR_HUNDRED_YEARS = 1.26227808e+13;
77    var SECTION         =  "15.9.1.1-2";
78    var tc              = 0;
79    var testcases       = new Array();
80
81    test();
82
83