Sha256: be624a35797c4dc039bdf79315419f68cf26e1ddae35e60c9529fac4bfd210f8

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2011 Apple Inc. and contributors.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================

/*global module test equals context ok same */

module("SC.Validator.Date");

test("Converts into date if a value is given",function(){
    var date = new Date(1234947136000),
        utcDate = new Date(Number(date) + (date.getTimezoneOffset() * 60000)); // Adjust for timezone offset

    var c = SC.Validator.Date.fieldValueForObject(Number(utcDate),'','');
    var expected = "Feb 18, 2009 8:52:16 AM";
    ok(c === expected, "Number converted to date format. Expected: (%@) but got (%@)".fmt(expected, c));
});

test("Converts into number when date string is given", function(){
    var expected = 1234918336000;
    var date = new Date(expected);
    var d = SC.Validator.Date.objectForFieldValue(date.format('NNN d, yyyy h:mm:ss a'),'','');
    ok(d === expected, "Date String compared with value in seconds. Expected: (%@) but got (%@)".fmt(expected, d));
    ok(SC.typeOf(d) == "number", "Number is obtained");
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sproutcore-1.5.0.rc.2 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/date.js
sproutcore-1.5.0.rc.1 lib/frameworks/sproutcore/frameworks/foundation/tests/validators/date.js