forked from danibram/time-tracker-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.js
More file actions
48 lines (43 loc) · 1.46 KB
/
Copy pathUtils.js
File metadata and controls
48 lines (43 loc) · 1.46 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var recognizeModifierTiming = exports.recognizeModifierTiming = function recognizeModifierTiming(string) {
var r = /(\d{1,})([hms])/g;
var arr = undefined;
var res = [];
while ((arr = r.exec(string)) !== null) {
res.push({
value: arr[1],
momentKey: arr[2]
});
}
return res;
};
var calcRate = exports.calcRate = function calcRate(rate, total) {
var amount = undefined;
var mod = rate.substr(rate.length - 1);
var value = rate.slice(0, rate.length - 1);
switch (mod) {
case 'h':
amount = total / 60 / 60 * parseFloat(value);
break;
case 'm':
amount = total / 60 * parseFloat(value);
break;
case 's':
amount = total * parseFloat(value);
break;
}
return amount.toFixed(2);
};
var humanParseDiff = exports.humanParseDiff = function humanParseDiff(secs) {
var hours = Math.floor(secs / 3600);
var minutes = Math.floor((secs - hours * 3600) / 60);
var seconds = secs - hours * 3600 - minutes * 60;
hours = hours == 0 ? '' : (hours < 10 ? '0' + hours : hours) + 'h ';
minutes = minutes == 0 && hours == '' ? '' : (minutes < 10 ? '0' + minutes : minutes) + 'm ';
seconds = seconds == 0 ? '' : (seconds < 10 ? '0' + seconds : seconds) + 's';
return hours + minutes + seconds;
};
//# sourceMappingURL=Utils.js.map