mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2024-08-14 23:57:27 +00:00 
			
		
		
		
	Add timeutils helper.
This commit is contained in:
		
							parent
							
								
									2c4ccc2a8f
								
							
						
					
					
						commit
						cefef1b8db
					
				
					 1 changed files with 20 additions and 0 deletions
				
			
		
							
								
								
									
										20
									
								
								src/utils/TimeUtils.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/utils/TimeUtils.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,20 @@
 | 
			
		|||
export default {
 | 
			
		||||
    timeFormat: function (duration) {
 | 
			
		||||
        var pad = function (num, size) {
 | 
			
		||||
            return ("000" + num).slice(size * -1);
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        var time = parseFloat(duration).toFixed(3),
 | 
			
		||||
            hours = Math.floor(time / 60 / 60),
 | 
			
		||||
            minutes = Math.floor(time / 60) % 60,
 | 
			
		||||
            seconds = Math.floor(time - minutes * 60);
 | 
			
		||||
 | 
			
		||||
        var str = "";
 | 
			
		||||
 | 
			
		||||
        if (hours > 0) str += pad(hours, 2) + ":";
 | 
			
		||||
 | 
			
		||||
        str += pad(minutes, 2) + ":" + pad(seconds, 2);
 | 
			
		||||
 | 
			
		||||
        return str;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue