'use strict';

var mod = angular.module('bananaraceApp.filters', []);

// mod.filter('mstotext', ['milliseconds', function(milliseconds) {

//   function msToTextFilter(input) {
//     return 'filtered'+input;
//   }

//   return msToTextFilter;
// }]);

mod.filter('secondsToString', function() {
    return function(seconds) {
        var minutes = Math.floor(seconds/60);
				var secondsleft = seconds-(minutes*60);

				var padWithZeroes = function(input, desiredlength) {
					var str = input+"";
					while(str.length<desiredlength) {
						str = "0"+str;
					}
					return str;
				};

				var seconds = Math.floor(secondsleft);
				var decimals = secondsleft-seconds;

				return padWithZeroes(minutes, 2)+':'+padWithZeroes(seconds, 2)+"."+padWithZeroes(Math.floor(decimals*10),1);
    };
});
