js/src/tests/ecma/Date/15.9.1.1-1.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma/Date/15.9.1.1-1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +
    1.10 +/**
    1.11 +   File Name:          15.9.1.1-1.js
    1.12 +   ECMA Section:       15.9.1.1 Time Range
    1.13 +   Description:
    1.14 +   - leap seconds are ignored
    1.15 +   - assume 86400000 ms / day
    1.16 +   - numbers range fom +/- 9,007,199,254,740,991
    1.17 +   - ms precision for any instant that is within
    1.18 +   approximately +/-285,616 years from 1 jan 1970
    1.19 +   UTC
    1.20 +   - range of times supported is -100,000,000 days
    1.21 +   to 100,000,000 days from 1 jan 1970 12:00 am
    1.22 +   - time supported is 8.64e5*10e8 milliseconds from
    1.23 +   1 jan 1970 UTC  (+/-273972.6027397 years)
    1.24 +
    1.25 +   -   this test generates its own data -- it does not
    1.26 +   read data from a file.
    1.27 +   Author:             christine@netscape.com
    1.28 +   Date:               7 july 1997
    1.29 +
    1.30 +   Static variables:
    1.31 +   FOUR_HUNDRED_YEARS
    1.32 +
    1.33 +*/
    1.34 +
    1.35 +//  every one hundred years contains:
    1.36 +//    24 years with 366 days
    1.37 +//
    1.38 +//  every four hundred years contains:
    1.39 +//    97 years with 366 days
    1.40 +//   303 years with 365 days
    1.41 +//
    1.42 +//   86400000*365*97    =    3067372800000
    1.43 +//  +86400000*366*303   =  + 9555408000000
    1.44 +//                      =    1.26227808e+13
    1.45 +var FOUR_HUNDRED_YEARS = 1.26227808e+13;
    1.46 +var SECTION         =  "15.9.1.1-1";
    1.47 +
    1.48 +writeHeaderToLog("15.9.1.1 Time Range");
    1.49 +
    1.50 +var M_SECS;
    1.51 +var CURRENT_YEAR;
    1.52 +
    1.53 +for ( M_SECS = 0, CURRENT_YEAR = 1970;
    1.54 +      M_SECS < 8640000000000000;
    1.55 +      M_SECS += FOUR_HUNDRED_YEARS, CURRENT_YEAR += 400 ) {
    1.56 +
    1.57 +  new TestCase( SECTION,  
    1.58 +		"new Date("+M_SECS+")",
    1.59 +		CURRENT_YEAR,
    1.60 +		(new Date( M_SECS)).getUTCFullYear() );
    1.61 +}
    1.62 +
    1.63 +test();
    1.64 +

mercurial