@osimatic/helpers-js 1.1.15 → 1.1.17
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 +14 -0
- package/package.json +1 -1
- package/string.js +4 -0
package/date_time.js
CHANGED
|
@@ -88,6 +88,13 @@ class DateTime {
|
|
|
88
88
|
return this.getSqlDate(jsDate)+' '+this.getSqlTime(jsDate);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
static getDateForInputDate(jsDate, timeZone="Europe/Paris") {
|
|
92
|
+
return this.getSqlDate(jsDate, timeZone);
|
|
93
|
+
}
|
|
94
|
+
static getTimeForInputTime(jsDate, timeZone="Europe/Paris") {
|
|
95
|
+
return jsDate.toLocaleTimeString('en-GB', {hour: 'numeric', timeZone: timeZone, hour12: false}).padStart(2, '0')+':'+jsDate.toLocaleTimeString('en-GB', {minute: 'numeric', timeZone: timeZone, hour12: false}).padStart(2, '0');
|
|
96
|
+
}
|
|
97
|
+
|
|
91
98
|
static getTimestamp(jsDate) {
|
|
92
99
|
return jsDate.getTime();
|
|
93
100
|
}
|
|
@@ -332,6 +339,13 @@ class TimestampUnix {
|
|
|
332
339
|
return DateTime.getSqlTime(this.parse(timestamp), timeZone);
|
|
333
340
|
}
|
|
334
341
|
|
|
342
|
+
static getDateForInputDate(timestamp, timeZone="Europe/Paris") {
|
|
343
|
+
return DateTime.getDateForInputDate(this.parse(timestamp), timeZone);
|
|
344
|
+
}
|
|
345
|
+
static getTimeForInputTime(timestamp, timeZone="Europe/Paris") {
|
|
346
|
+
return DateTime.getTimeForInputTime(this.parse(timestamp), timeZone);
|
|
347
|
+
}
|
|
348
|
+
|
|
335
349
|
static isDateEqual(timestamp1, timestamp2) {
|
|
336
350
|
return DateTime.isDateEqual(this.parse(timestamp1), this.parse(timestamp2));
|
|
337
351
|
}
|
package/package.json
CHANGED
package/string.js
CHANGED
|
@@ -115,6 +115,10 @@ String.prototype.ucwords = String.prototype.ucwords || function() {
|
|
|
115
115
|
String.prototype.capitalize = String.prototype.capitalize || function() {
|
|
116
116
|
return this.charAt(0).toUpperCase() + this.slice(1);
|
|
117
117
|
}
|
|
118
|
+
String.prototype.acronym = String.prototype.acronym || function() {
|
|
119
|
+
return this.split(' ').map(word => word.charAt(0)).join('');
|
|
120
|
+
//return this.match(/\b(\w)/g).join('');
|
|
121
|
+
}
|
|
118
122
|
|
|
119
123
|
String.prototype.encodeForHtmlDataAttribute = String.prototype.encodeForHtmlDataAttribute || function() {
|
|
120
124
|
return this.replace(/\"/g, "'");
|