js/src/tests/ecma_5/extensions/15.9.4.2.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_5/extensions/15.9.4.2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,59 @@
     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 +var BUGNUMBER = 682754;
    1.11 +
    1.12 +
    1.13 +//-----------------------------------------------------------------------------
    1.14 +test();
    1.15 +//-----------------------------------------------------------------------------
    1.16 +
    1.17 +function iso(d)
    1.18 +{
    1.19 +  return new Date(d).toISOString();
    1.20 +}
    1.21 +
    1.22 +function check(s, millis){
    1.23 +  description = "Date.parse('"+s+"') == '"+iso(millis)+"'";
    1.24 +  expected = millis;
    1.25 +  actual = Date.parse(s);
    1.26 +  reportCompare(expected, actual, description);
    1.27 +}
    1.28 +
    1.29 +function checkInvalid(s)
    1.30 +{
    1.31 +  description = "Date.parse('"+s+"') produces invalid date";
    1.32 +  expected = NaN;
    1.33 +  actual = Date.parse(s);
    1.34 +  reportCompare(expected, actual, description);
    1.35 +}
    1.36 +
    1.37 +function dd(year, month, day, hour, minute, second, millis){
    1.38 +  return Date.UTC(year, month-1, day, hour, minute, second, millis);
    1.39 +}
    1.40 +
    1.41 +function TZAtDate(d){
    1.42 +  return d.getTimezoneOffset() * 60000;
    1.43 +}
    1.44 +
    1.45 +function TZInMonth(month){
    1.46 +  return TZAtDate(new Date(dd(2009,month,1,0,0,0,0)));
    1.47 +}
    1.48 +
    1.49 +function test()
    1.50 +{
    1.51 +  enterFunc ('test');
    1.52 +  printBugNumber(BUGNUMBER);
    1.53 +
    1.54 +  JanTZ = TZInMonth(1);
    1.55 +  JulTZ = TZInMonth(7);
    1.56 +  CurrTZ = TZAtDate(new Date());
    1.57 +
    1.58 +  // Allow non-standard "-0700" as timezone, not just "-07:00"
    1.59 +  check("2009-07-23T00:53:21.001-0700", dd(2009,7,23,7,53,21,1));
    1.60 +
    1.61 +  exitFunc ('test');
    1.62 +}

mercurial