• 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-1.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
37                        -   this test generates its own data -- it does not
38                            read data from a file.
39    Author:             christine@netscape.com
40    Date:               7 july 1997
41
42    Static variables:
43        FOUR_HUNDRED_YEARS
44
45*/
46
47function test() {
48    writeHeaderToLog("15.8.1.1 Time Range");
49
50    for (  M_SECS = 0, CURRENT_YEAR = 1970;
51                 M_SECS < 8640000000000000;
52                tc++,   M_SECS += FOUR_HUNDRED_YEARS, CURRENT_YEAR += 400 ) {
53
54        testcases[tc] = new TestCase( SECTION,   "new Date("+M_SECS+")", CURRENT_YEAR, (new Date( M_SECS)).getUTCFullYear() );
55
56        testcases[tc].passed =  writeTestCaseResult(
57                                testcases[tc].expect,
58                                testcases[tc].actual,
59                                testcases[tc].description +" = "+
60                                testcases[tc].actual );
61
62        if ( ! testcases[tc].passed ) {
63            testcases[tc].reason = "wrong year value";
64        }
65    }
66
67    stopTest();
68
69    return ( testcases );
70}
71
72//  every one hundred years contains:
73//    24 years with 366 days
74//
75//  every four hundred years contains:
76//    97 years with 366 days
77//   303 years with 365 days
78//
79//   86400000*365*97    =    3067372800000
80//  +86400000*366*303   =  + 9555408000000
81//                      =    1.26227808e+13
82    var FOUR_HUNDRED_YEARS = 1.26227808e+13;
83    var SECTION         =  "15.9.1.1-1";
84    var tc              = 0;
85    var testcases       = new Array();
86
87    test();
88