-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathconvertTime.js
More file actions
26 lines (21 loc) · 902 Bytes
/
convertTime.js
File metadata and controls
26 lines (21 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (seconds, timeFormats) {
if (Number.isNaN(seconds)) {
return '';
}
var myTime = new Date(seconds * 1000);
var hour = myTime.getUTCHours();
var min = timeFormats.showHour ? myTime.getUTCMinutes() : myTime.getUTCMinutes() + hour * 60;
var sec = timeFormats.showMin ? myTime.getUTCSeconds() : myTime.getUTCSeconds() + min * 60;
var strHour = timeFormats.padHour && hour < 10 ? '0' + hour : hour;
var strMin = timeFormats.padMin && min < 10 ? '0' + min : min;
var strSec = timeFormats.padSec && sec < 10 ? '0' + sec : sec;
var strTime = '';
strTime += timeFormats.showHour ? strHour + timeFormats.sepHour : '';
strTime += timeFormats.showMin ? strMin + timeFormats.sepMin : '';
strTime += timeFormats.showSec ? strSec + timeFormats.sepSec : '';
return strTime;
};