function count_time(m,arr){
var arr= arr;
var h = Math.floor(m / 60);
m -= h * 60;
var result=(h?h>=10?h:'0'+h:'00')+':'+(m?m>=10?m:'0'+m:'00');
console.log(result);
}
var t_json=[
"08:00 ",
"10:00 ",
"11:50 ",
"12:00 ",
"13:00 ",
"15:00 ",
"16:00 ",
"18:00 ",
"19:00 ",
"07:57 ",
"12:00 ",
]
function test1(arr) {
var th_time = new Date();
var th_time1= new Date();
var noon12 = new Date("2000/1/1 12:00" );
var noon13 = new Date("2000/1/1 13:20" );
for (var i = 0; i < arr.length; i++) {
th_time = new Date("2000/1/1 " + arr[i]);
th_time1 = new Date("2000/1/1 " + arr[i+1]);
if (th_time < th_time1){
}
else if (th_time < noon12 && th_time1 >= noon12){
minut += (noon12-th_time)/1000/60;
}
else if (th_time < noon13 && th_time1 > noon13){
minut += (noon13-th_time)/1000/60;
continue;
}
else if (arr[i] == arr[arr.length-1]) {
count_time(minut);
}
}
}
test1(t_json);
一天从8点开始 18点结束
一天内有多个时间点 12点到14点的时间点是不被计算的,并且当前时间点如果有小于或大于临近12点,那么就要减或加10分钟 14 18点也一样。
每天的时间差都要统计..
我在if方面 总是想不出来应该怎么写。。。