@osimatic/helpers-js 1.1.70 → 1.1.71

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 +15 -2
  2. package/package.json +1 -1
package/date_time.js CHANGED
@@ -96,7 +96,7 @@ class DateTime {
96
96
  }
97
97
 
98
98
  static getTimestamp(jsDate) {
99
- return jsDate.getTime()/1000;
99
+ return Math.trunc(jsDate.getTime()/1000);
100
100
  }
101
101
 
102
102
  static getDateDigitalDisplay(jsDate, locale="fr-FR", timeZone="Europe/Paris") {
@@ -298,6 +298,20 @@ class DateTime {
298
298
  }
299
299
  return parseInt(Math.round((timestamp2-timestamp1)/86400));
300
300
  }
301
+
302
+ static addDays(date, days) {
303
+ date.setUTCDate(date.getUTCDate() + days);
304
+ return date;
305
+ }
306
+
307
+ static addMonths(date, months) {
308
+ let d = date.getDate();
309
+ date.setMonth(date.getMonth() + +months);
310
+ if (date.getDate() !== d) {
311
+ date.setDate(0);
312
+ }
313
+ return date;
314
+ }
301
315
  }
302
316
 
303
317
  class TimestampUnix {
@@ -576,5 +590,4 @@ class SqlDateTime {
576
590
 
577
591
  }
578
592
 
579
-
580
593
  module.exports = { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.1.70",
3
+ "version": "1.1.71",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"