1 function custom_time(h,m) {
7 QUnit.test("kivi.parse_time function for German time style with colon", function( assert ) {
8 assert.equalTimes = function(actual, expected, message) {
10 var result = (expected === undefined && actual === undefined)
11 || (expected === null && actual === null)
12 || (expected instanceof Date && actual instanceof Date &&
13 expected.getHours() == actual.getHours() &&
14 expected.getMinutes() == actual.getMinutes());
24 kivi.setup_formats({ times: "hh:mm" });
26 assert.equalTimes(kivi.parse_time("12:34"), custom_time(12,34));
27 assert.equalTimes(kivi.parse_time("10:00"), custom_time(10,0));
28 assert.equalTimes(kivi.parse_time(" 12 : 23 ") - custom_time(12,23));
30 assert.equalTimes(kivi.parse_time("00:20"), custom_time(0,20));
32 assert.equalTimes(kivi.parse_time("23:60"), custom_time(23,60));
34 assert.equalTimes(kivi.parse_time("1142"), custom_time(11,42));
36 assert.equalTimes(kivi.parse_time("Totally Invalid!"), undefined);
37 assert.equalTimes(kivi.parse_time("."), undefined);
38 assert.equalTimes(kivi.parse_time(".."), undefined);
39 assert.equalTimes(kivi.parse_time(":"), undefined);
40 assert.equalTimes(kivi.parse_time("::"), undefined);
41 assert.equalTimes(kivi.parse_time("aa:bb"), undefined);
42 assert.equalTimes(kivi.parse_time("aasd:bbaf"), undefined);
43 assert.equalTimes(kivi.parse_time(""), null);
44 assert.equalTimes(kivi.parse_time("0"), new Date());
45 assert.equalTimes(kivi.parse_time("29:20008"), custom_time(29,20008));