您获得该输出的原因有两个:
-
tth
到
片刻
期间
.
-
以下是获得输出的两种方法(检查console中的最后几行以了解两种输出之间的差异):
注意:由于您的问题与angularjs无关,所以我将展示简单的JS代码。
var attendance = [
'00:47:21',
'00:00:25',
'00:00:08',
'00:00:03',
'00:00:37',
'16:12:12',
'04:44:22',
'01:39:03',
'00:01:58',
'16:17:29'
];
var tth = 0;
for( var x=0; x < attendance.length; x++){
tth += moment.duration(attendance[x]);
var d = moment.duration(tth);
console.log(moment(tth).format('HH:mm:ss') + ' with number of days >> ' + d.days() + ' ' + d.hours() + ':' + d.minutes() + ':' + d.seconds() );
console.log(moment(tth).format('HH:mm:ss') + ' with hours exceeding 24 ## ' + parseInt(d.asHours()) + ':' + d.minutes() + ':' + d.seconds() );
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.min.js"></script>