# HG changeset patch # User hamidouk # Date 1321442898 -3600 # Node ID cafaa694b709d06ebc09d5280df549ca96750790 # Parent 95c6b77f005e826f595a2655f6ccfc17908e35f6 fixed the conversion function to accomodate mustache. diff -r 95c6b77f005e -r cafaa694b709 src/js/utils.js --- a/src/js/utils.js Wed Nov 16 11:40:57 2011 +0100 +++ b/src/js/utils.js Wed Nov 16 12:28:18 2011 +0100 @@ -34,12 +34,12 @@ /* convert a number of seconds to a tuple of the form [hours, minutes, seconds] */ -IriSP.secondsToTime = function(secs) { +IriSP.secondsToTime = function(secs) { var hours = Math.abs(parseInt( secs / 3600 ) % 24); var minutes = Math.abs(parseInt( secs / 60 ) % 60); - var seconds = Math.abs(secs % 60); + var seconds = parseFloat(Math.abs(secs % 60).toFixed(0)); - return [hours, minutes, seconds]; + return {"hours" : hours, "minutes" : minutes, "seconds" : seconds}; } /* for ie compatibility if (Object.prototype.__defineGetter__&&!Object.defineProperty) { diff -r 95c6b77f005e -r cafaa694b709 unittests/tests/utils.js --- a/unittests/tests/utils.js Wed Nov 16 11:40:57 2011 +0100 +++ b/unittests/tests/utils.js Wed Nov 16 12:28:18 2011 +0100 @@ -27,9 +27,10 @@ test("test function to convert from seconds to a time", function() { var h = 13, m = 7, s = 41; var t = 13 * 3600 + 7* 60 + 41; - deepEqual(IriSP.secondsToTime(t), [h, m, s], "the converted time is correct"); + deepEqual(IriSP.secondsToTime(t), {"hours" : h, "minutes" : m, "seconds" : s}, + "the converted time is correct"); t = -t; - deepEqual(IriSP.secondsToTime(t), [h, m, s], "the function is immune to negative numbers."); + deepEqual(IriSP.secondsToTime(t), {"hours" : h, "minutes" : m, "seconds" : s}, "the function is immune to negative numbers."); }); } \ No newline at end of file