import {Pipe, PipeTransform} from '@angular/core';

@Pipe({
    name: 'formatTime',
})
export class FormatTimePipe implements PipeTransform {
    /**
     * 将秒转化为时分秒
     * value   秒
     */
    transform(value, ...args) {
        let hourse = (Math.floor(value / 3600)).toString();
        hourse = (hourse.length > 1 ? hourse : '0' + hourse);
        let minutes =<any> Math.floor(value / 60).toString();
        minutes = minutes % 60 === 0 ? 0:minutes;
        minutes = (minutes.length > 1 ? minutes : '0' + minutes);
        let seconds = Math.floor(value % 60).toString();
        seconds = (seconds.length > 1 ? seconds : '0' + seconds);
        const timeText = hourse + ":" + minutes + ":" + seconds;
        return timeText;
    }
}
