@8ms/helpers 1.6.2 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Convert a number
|
|
3
|
-
* https://
|
|
2
|
+
* Convert a number of seconds into HH:MM:SS
|
|
3
|
+
* https://www.codevertiser.com/convert-seconds-to-hours-and-minutes-javascript/
|
|
4
4
|
*/
|
|
5
5
|
declare const getDurationHours: ({ seconds }: {
|
|
6
6
|
seconds: number;
|
package/date/getDurationHours.js
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const intervalToDuration_1 = __importDefault(require("date-fns/intervalToDuration"));
|
|
7
3
|
/**
|
|
8
|
-
* Convert a number
|
|
9
|
-
* https://
|
|
4
|
+
* Convert a number of seconds into HH:MM:SS
|
|
5
|
+
* https://www.codevertiser.com/convert-seconds-to-hours-and-minutes-javascript/
|
|
10
6
|
*/
|
|
11
7
|
const getDurationHours = ({ seconds }) => {
|
|
12
8
|
let response = '00:00:00';
|
|
13
9
|
if (seconds > 0) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
const calculated = {
|
|
11
|
+
hours: Math.floor(seconds / 3600),
|
|
12
|
+
minutes: Math.floor((seconds % 3600) / 60),
|
|
13
|
+
seconds: seconds % 60,
|
|
14
|
+
};
|
|
18
15
|
const output = {
|
|
19
|
-
hours:
|
|
20
|
-
minutes:
|
|
21
|
-
seconds:
|
|
16
|
+
hours: calculated.hours < 10 ? '0' + calculated.hours : calculated.hours,
|
|
17
|
+
minutes: calculated.minutes < 10 ? '0' + calculated.minutes : calculated.minutes,
|
|
18
|
+
seconds: calculated.seconds < 10 ? '0' + calculated.seconds : calculated.seconds,
|
|
22
19
|
};
|
|
23
20
|
response = `${output.hours}:${output.minutes}:${output.seconds}`;
|
|
24
21
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Convert a number
|
|
3
|
-
* https://
|
|
2
|
+
* Convert a number of seconds into MM:SS
|
|
3
|
+
* https://www.codevertiser.com/convert-seconds-to-hours-and-minutes-javascript/
|
|
4
4
|
*/
|
|
5
5
|
declare const getDurationMinutes: ({ seconds }: {
|
|
6
6
|
seconds: number;
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const intervalToDuration_1 = __importDefault(require("date-fns/intervalToDuration"));
|
|
7
3
|
/**
|
|
8
|
-
* Convert a number
|
|
9
|
-
* https://
|
|
4
|
+
* Convert a number of seconds into MM:SS
|
|
5
|
+
* https://www.codevertiser.com/convert-seconds-to-hours-and-minutes-javascript/
|
|
10
6
|
*/
|
|
11
7
|
const getDurationMinutes = ({ seconds }) => {
|
|
12
8
|
let response = '00:00';
|
|
13
9
|
if (seconds > 0) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
10
|
+
const calculated = {
|
|
11
|
+
minutes: Math.floor((seconds % 3600) / 60),
|
|
12
|
+
seconds: seconds % 60,
|
|
13
|
+
};
|
|
18
14
|
const output = {
|
|
19
|
-
minutes:
|
|
20
|
-
seconds:
|
|
15
|
+
minutes: calculated.minutes < 10 ? '0' + calculated.minutes : calculated.minutes,
|
|
16
|
+
seconds: calculated.seconds < 10 ? '0' + calculated.seconds : calculated.seconds,
|
|
21
17
|
};
|
|
22
18
|
response = `${output.minutes}:${output.seconds}`;
|
|
23
19
|
}
|