@osimatic/helpers-js 1.1.16 → 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.
Files changed (2) hide show
  1. package/date_time.js +14 -0
  2. package/package.json +1 -1
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.1.16",
3
+ "version": "1.1.17",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"