edf182180c8a8ac1bfa3abf2fba4b968c417dc15
[platform/framework/web/crosswalk-tizen.git] /
1 define(['../math/countSteps', '../number/pad'], function(countSteps, pad){
2
3     var HOUR = 3600000,
4         MINUTE = 60000,
5         SECOND = 1000;
6
7     /**
8      * Format timestamp into a time string.
9      */
10     function toTimeString(ms){
11         var h = ms < HOUR   ? 0 : countSteps(ms, HOUR),
12             m = ms < MINUTE ? 0 : countSteps(ms, MINUTE, 60),
13             s = ms < SECOND ? 0 : countSteps(ms, SECOND, 60),
14             str = '';
15
16         str += h? h + ':' : '';
17         str += pad(m, 2) + ':';
18         str += pad(s, 2);
19
20         return str;
21     }
22     return toTimeString;
23 });