1 |
|
2 |
|
3 |
|
4 | module.exports = function formatTime(t, options, roundToMultipleOf){
|
5 | function round(input) {
|
6 | if (roundToMultipleOf) {
|
7 | return roundToMultipleOf * Math.round(input / roundToMultipleOf);
|
8 | } else {
|
9 | return input
|
10 | }
|
11 | }
|
12 |
|
13 |
|
14 | function autopadding(v){
|
15 | return (options.autopaddingChar + v).slice(-2);
|
16 | }
|
17 |
|
18 |
|
19 | if (t > 3600) {
|
20 | return autopadding(Math.floor(t / 3600)) + 'h' + autopadding(round((t % 3600) / 60)) + 'm';
|
21 |
|
22 |
|
23 | } else if (t > 60) {
|
24 | return autopadding(Math.floor(t / 60)) + 'm' + autopadding(round((t % 60))) + 's';
|
25 |
|
26 |
|
27 | } else if (t > 10) {
|
28 | return autopadding(round(t)) + 's';
|
29 |
|
30 |
|
31 | }else{
|
32 | return autopadding(t) + 's';
|
33 | }
|
34 | } |
\ | No newline at end of file |