@osimatic/helpers-js 1.2.7 → 1.2.8
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.
- package/date_time.js +3 -3
- package/duration.js +13 -11
- package/package.json +1 -1
package/date_time.js
CHANGED
|
@@ -121,7 +121,7 @@ class DateTime {
|
|
|
121
121
|
|
|
122
122
|
static getTimeDisplayWithNbDays(jsDate, jsPreviousDate, locale="fr-FR", timeZone="Europe/Paris") {
|
|
123
123
|
let str = this.getTimeDisplay(jsDate, locale, timeZone);
|
|
124
|
-
if (jsPreviousDate
|
|
124
|
+
if (jsPreviousDate !== 0 && jsPreviousDate != null) {
|
|
125
125
|
let nbDaysDiff = this.getNbDayBetweenTwo(jsPreviousDate, jsDate, false);
|
|
126
126
|
if (nbDaysDiff > 0) {
|
|
127
127
|
str += ' (J+'+nbDaysDiff+')';
|
|
@@ -238,7 +238,7 @@ class DateTime {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
static isDateEqual(jsDate1, jsDate2) {
|
|
241
|
-
return (jsDate1.getFullYear()
|
|
241
|
+
return (jsDate1.getFullYear() === jsDate2.getFullYear() && jsDate1.getMonth() === jsDate2.getMonth() && jsDate1.getDate() === jsDate2.getDate());
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
static isDateInThePast(jsDate) {
|
|
@@ -465,7 +465,7 @@ class SqlTime {
|
|
|
465
465
|
return null;
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
-
if ((sqlTime.match(/\:/g) || []).length
|
|
468
|
+
if ((sqlTime.match(/\:/g) || []).length === 1) {
|
|
469
469
|
sqlTime += ':00';
|
|
470
470
|
}
|
|
471
471
|
|
package/duration.js
CHANGED
|
@@ -51,18 +51,20 @@ class Duration {
|
|
|
51
51
|
return (durationInSecondsOriginal < 0 ? '- ' : '')+hours+':'+minutes+(displayMode==='input_time'?':':'.')+seconds;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
static convertToDurationInHourStringDisplay(durationInSeconds,
|
|
54
|
+
static convertToDurationInHourStringDisplay(durationInSeconds, withSeconds=true, withMinutes=true, withMinuteLabel=true, fullLabel=false, hideHourIfZeroHour=false) {
|
|
55
55
|
durationInSeconds = Math.round(durationInSeconds);
|
|
56
56
|
|
|
57
57
|
// Heures
|
|
58
58
|
let strHeure = '';
|
|
59
59
|
let nbHeures = this.getNbHoursOfDurationInSeconds(durationInSeconds);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
if (!hideHourIfZeroHour || nbHeures > 0) {
|
|
61
|
+
strHeure += nbHeures;
|
|
62
|
+
if (fullLabel) {
|
|
63
|
+
strHeure += ' heure'+(nbHeures>1?'s':'');
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
strHeure += 'h';
|
|
67
|
+
}
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
// Minutes
|
|
@@ -73,8 +75,8 @@ class Duration {
|
|
|
73
75
|
strMinute += ' ';
|
|
74
76
|
//strMinute += sprintf('%02d', nbMinutes);
|
|
75
77
|
strMinute += nbMinutes.toString().padStart(2, '0');
|
|
76
|
-
if (
|
|
77
|
-
if (
|
|
78
|
+
if (withMinuteLabel) {
|
|
79
|
+
if (fullLabel) {
|
|
78
80
|
strMinute += ' minute'+(nbMinutes>1?'s':'');
|
|
79
81
|
}
|
|
80
82
|
else {
|
|
@@ -85,12 +87,12 @@ class Duration {
|
|
|
85
87
|
|
|
86
88
|
// Secondes
|
|
87
89
|
let strSeconde = '';
|
|
88
|
-
if (
|
|
90
|
+
if (withSeconds) {
|
|
89
91
|
let nbSecondes = this.getNbSecondsRemainingOfDurationInSeconds(durationInSeconds);
|
|
90
92
|
strSeconde += ' ';
|
|
91
93
|
//strSeconde += sprintf('%02d', nbSecondes);
|
|
92
94
|
strSeconde += nbSecondes.toString().padStart(2, '0');
|
|
93
|
-
if (
|
|
95
|
+
if (fullLabel) {
|
|
94
96
|
strSeconde += ' seconde'+(nbSecondes>1?'s':'');
|
|
95
97
|
}
|
|
96
98
|
else {
|