data:[{time :9:15}, {time :9:16}, {time :9:17}, {time :9:18}, {time :9:19}, {time :10:15}, {time :10:16}, {time :10:17}, {time :10:18} ]
this array I am getting from the server and am printing it in the table on the screen . But if you can see this data is not in continues form. If data is not in an array I want to show that data and show it on screen. Suppose data is not present after 9:19 is not present then my o/p should be 9:15 9:16.....9:19 9:20 9:21 9:22 ...10:14.
var data=[{time :'9:15'}, {time :'9:16'}, {time :'9:17'}, {time :'9:18'}, {time :'9:19'}, {time :'10:15'}, {time :'10:16'}, {time :'10:17'}, {time :'10:18'}];
var h = th = +data[0].time.split(':')[0];
var m = tm = data[0].time.split(':')[1] - 1;
var h2 = +data[data.length - 1].time.split(':')[0];
var m2 = +data[data.length - 1].time.split(':')[1];
var result = [];
do {
if(h2 == th && m2 == tm)
break;
tm++;
if(tm == 60){
tm=0;
th++;
}
result.push({time: th+':'+tm});
}while(true);
console.log(result);
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加