@osimatic/helpers-js 1.1.67 → 1.1.69

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.
Files changed (3) hide show
  1. package/duration.js +11 -0
  2. package/number.js +1 -1
  3. package/package.json +1 -1
package/duration.js CHANGED
@@ -18,6 +18,17 @@ class Duration {
18
18
 
19
19
  // ---------- Durée en seconde ----------
20
20
 
21
+ static convertInputTimeValueToDuration(inputTimeValue) {
22
+ if (null === inputTimeValue || -1 === inputTimeValue.indexOf(':')) {
23
+ return 0;
24
+ }
25
+ let arrayTime = inputTimeValue.split(':');
26
+ const nbHours = typeof arrayTime[0] != 'undefined' ? parseInt(arrayTime[0]) || 0 : 0;
27
+ const nbMinutes = typeof arrayTime[1] != 'undefined' ? parseInt(arrayTime[1]) || 0 : 0;
28
+ const nbSeconds = typeof arrayTime[2] != 'undefined' ? parseInt(arrayTime[2]) || 0 : 0;
29
+ return nbHours * 3600 + nbMinutes * 60 + nbSeconds;
30
+ }
31
+
21
32
  static convertToDurationAsInputTimeValue(durationInSeconds) {
22
33
  return Duration.convertToDurationInHourChronoDisplay(Math.abs(durationInSeconds), 'input_time');
23
34
  }
package/number.js CHANGED
@@ -88,7 +88,7 @@ Number.roundDecimal = Number.roundDecimal || function(number, precision) {
88
88
  }
89
89
 
90
90
  Math.getDecimals = Math.getDecimals || function(number) {
91
- return parseInt((number+"").split(".")[1]);
91
+ return parseInt((number+"").split(".")[1] || 0);
92
92
  }
93
93
 
94
94
  if (!Number.random) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.1.67",
3
+ "version": "1.1.69",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"