return parseFloat( str.match(/[\d.]+ms$/) || "0");\r
};\r
function sec() {\r
- var deg = str.match(/:[\d.]+$/) || "0",\r
- de = str.match(/[\d.]+s$/) || "0",\r
- d = str.match(/[\d.]+$/) || "0";\r
- return ( 1000*( parseFloat(deg) || parseFloat(de) || parseFloat(d) ) );\r
+ var deg = str.match(/[\d.]+s$/) || "0",\r
+ de = str.match(/[\d.]+$/) || "0";\r
+ return ( 1000*( parseFloat(deg) || parseFloat(de) ) );\r
};\r
function min() {\r
- var deg = str.match(/:\d\d:/) || "0",\r
- de = str.match(/[\d.]+min$/) || "0",\r
- d = str.match(/\d\d:[^:]+$/) || "0";\r
- return ( 60000*( parseFloat(deg) || parseFloat(de) || parseFloat(d) ) );\r
+ var deg = str.match(/[\d.]+min$/) || "0",\r
+ de = str.match(/\d\d:[^:]+$/) || "0";\r
+ return ( 60000*( parseFloat(deg) || parseFloat(de) ) );\r
};\r
function h() {\r
var deg = str.match(/\d+:\d\d:/) || "0",\r
expect(begin.offset("1h")).toEqual(60*60*1000);\r
expect(begin.offset("-1h")).toEqual(-3600000);\r
\r
+ expect(begin.offset("00:0")).toEqual(0);\r
+ expect(begin.offset("00:00:0.0")).toEqual(0);\r
+ expect(begin.offset("-00:0")).toEqual(0);\r
+ expect(begin.offset("-00:00:0.0")).toEqual(0);\r
+ expect(begin.offset("00:1")).toEqual(1000);\r
+ expect(begin.offset("-00:1")).toEqual(-1000);\r
+\r
expect(begin.offset()).toEqual(0);\r
} );\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
expect(begin.offset("1.25h")).toEqual(1.25 * 3600000);\r
expect(begin.offset("-0.20h")).toEqual(-0.20 * 3600000);\r
expect(begin.offset(".20h")).toEqual(0.20 * 3600000);\r
+\r
+ expect(begin.offset("00:10")).toEqual(10000);\r
+ expect(begin.offset("00:0.01")).toEqual(10);\r
+ expect(begin.offset("01:0.01")).toEqual(60010);\r
+ expect(begin.offset("10:0")).toEqual(600000);\r
+ expect(begin.offset("-00:10")).toEqual(-10000);\r
+ expect(begin.offset("-00:0.01")).toEqual(-10);\r
+ expect(begin.offset("-01:0.01")).toEqual(-60010);\r
+ expect(begin.offset("-10:0")).toEqual(-600000);\r
+ expect(begin.offset("00:00:1")).toEqual(1000);\r
+ expect(begin.offset("00:00:20")).toEqual(20000);\r
+ expect(begin.offset("00:11:20")).toEqual(11*60*1000 + 20000);\r
+ expect(begin.offset("12:11:20")).toEqual(12*60*60*1000 + 11*60*1000 + 20000);\r
+ expect(begin.offset("-10:0")).toEqual(-600000);\r
+ expect(begin.offset("-01:01:0.1")).toEqual(-1*60*60*1000 - 60000 - 100);\r
} );\r
/*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
it("should be this for the value (the invalid partion)", function() {\r
expect(begin.offset(begin.trim())).toEqual(0);\r
expect(begin.offset("ms")).toEqual(0);\r
expect(begin.offset(".s")).toEqual(0);\r
+ expect(begin.offset("10:")).toEqual(0);\r
+ expect(begin.offset("::")).toEqual(0);\r
+ expect(begin.offset("-:0")).toEqual(0);\r
+ expect(begin.offset("-::0")).toEqual(0);\r
} );\r
} );\r
\r