@osimatic/helpers-js 1.1.53 → 1.1.54

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 CHANGED
@@ -161,7 +161,7 @@ class DateTime {
161
161
  }
162
162
 
163
163
  static getNbDaysInMonth(year, month) {
164
- return new Date(year, month, 0).getDate();
164
+ return new Date(Date.UTC(year, month, 0)).getDate();
165
165
  }
166
166
 
167
167
  static getMonthNameByMonth(month, locale="fr-FR", isShort=false) {
@@ -180,61 +180,61 @@ class DateTime {
180
180
 
181
181
  static getFirstDayOfWeek(date) {
182
182
  let firstDayOfWeek = new Date(date);
183
- const day = date.getDay();
184
- firstDayOfWeek.setDate(date.getDate() - day + (0 === day ? -6:1)); // First day is the day of the month - the day of the week
183
+ const day = date.getUTCDay();
184
+ firstDayOfWeek.setUTCDate(date.getUTCDate() - day + (0 === day ? -6:1)); // First day is the day of the month - the day of the week
185
185
  return firstDayOfWeek;
186
186
  }
187
187
 
188
188
  static getLastDayOfWeek(date) {
189
189
  let lastDayOfWeek = this.getFirstDayOfWeek(date);
190
- lastDayOfWeek.setDate(lastDayOfWeek.getDate() + 6); // last day is the first day + 6
190
+ lastDayOfWeek.setUTCDate(lastDayOfWeek.getUTCDate() + 6); // last day is the first day + 6
191
191
  return lastDayOfWeek;
192
192
  }
193
193
 
194
194
  static getFirstDayOfMonth(date) {
195
- return this.getFirstDayOfMonthAndYear(date.getFullYear(), date.getMonth()+1);
195
+ return this.getFirstDayOfMonthAndYear(date.getUTCFullYear(), date.getUTCMonth()+1);
196
196
  }
197
197
 
198
198
  static getLastDayOfMonth(date) {
199
- return this.getLastDayOfMonthAndYear(date.getFullYear(), date.getMonth()+1);
199
+ return this.getLastDayOfMonthAndYear(date.getUTCFullYear(), date.getUTCMonth()+1);
200
200
  }
201
201
 
202
202
  static getFirstDayOfYear(date) {
203
- date.setDate(1);
204
- date.setMonth(0);
203
+ date.setUTCDate(1);
204
+ date.setUTCMonth(0);
205
205
  return new Date(date);
206
206
  }
207
207
 
208
208
  static getLastDayOfYear(date) {
209
- date.setDate(31);
210
- date.setMonth(11);
209
+ date.setUTCDate(31);
210
+ date.setUTCMonth(11);
211
211
  return new Date(date);
212
212
  }
213
213
 
214
214
  static getFirstDayOfWeekAndYear(year, week) {
215
- let simple = new Date(year, 0, 1 + (week - 1) * 7);
215
+ let simple = new Date(Date.UTC(year, 0, 1 + (week - 1) * 7));
216
216
  let dow = simple.getDay();
217
217
  let ISOweekStart = simple;
218
218
  if (dow <= 4) {
219
- ISOweekStart.setDate(simple.getDate() - simple.getDay() + 1);
219
+ ISOweekStart.setUTCDate(simple.getUTCDate() - simple.getUTCDay() + 1);
220
220
  }
221
221
  else {
222
- ISOweekStart.setDate(simple.getDate() + 8 - simple.getDay());
222
+ ISOweekStart.setUTCDate(simple.getUTCDate() + 8 - simple.getUTCDay());
223
223
  }
224
224
  return ISOweekStart;
225
225
  }
226
226
  static getLastDayOfWeekAndYear(year, week) {
227
227
  let firstDayOfWeek = this.getFirstDayOfWeekAndYear(year, week);
228
- firstDayOfWeek.setDate(firstDayOfWeek.getDate()+6);
228
+ firstDayOfWeek.setUTCDate(firstDayOfWeek.getUTCDate()+6);
229
229
  return firstDayOfWeek;
230
230
  }
231
231
 
232
232
  static getFirstDayOfMonthAndYear(year, month) {
233
- return new Date(year, month-1, 1);
233
+ return new Date(Date.UTC(year, month-1, 1));
234
234
  }
235
235
 
236
236
  static getLastDayOfMonthAndYear(year, month) {
237
- return new Date(year, month, 0);
237
+ return new Date(Date.UTC(year, month, 0));
238
238
  }
239
239
 
240
240
  static isDateEqual(jsDate1, jsDate2) {
package/form_date.js CHANGED
@@ -63,7 +63,7 @@ class InputPeriod {
63
63
  }
64
64
  static selectFollowingDay(lien, nbDays) {
65
65
  let date = new Date();
66
- date.setDate(date.getDate() + nbDays);
66
+ date.setUTCDate(date.getUTCDate() + nbDays);
67
67
  this.selectPeriod(lien, date, date);
68
68
  }
69
69
 
@@ -76,7 +76,7 @@ class InputPeriod {
76
76
  }
77
77
  static selectFollowingWeek(lien, nbWeeks) {
78
78
  let date = new Date();
79
- date.setDate(date.getDate() + (7*nbWeeks));
79
+ date.setUTCDate(date.getUTCDate() + (7*nbWeeks));
80
80
  this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
81
81
  }
82
82
 
@@ -89,8 +89,8 @@ class InputPeriod {
89
89
  }
90
90
  static selectFollowingMonth(lien, nbMonths) {
91
91
  let date = new Date();
92
- date.setDate(1);
93
- date.setMonth(date.getMonth() + nbMonths);
92
+ date.setUTCDate(1);
93
+ date.setUTCMonth(date.getUTCMonth() + nbMonths);
94
94
  this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
95
95
  }
96
96
 
@@ -102,7 +102,7 @@ class InputPeriod {
102
102
  }
103
103
  static selectFollowingYear(lien, nbAnneesMoins) {
104
104
  let date = new Date();
105
- date.setFullYear(date.getFullYear() + nbAnneesMoins);
105
+ date.setUTCFullYear(date.getUTCFullYear() + nbAnneesMoins);
106
106
  this.selectPeriod(lien, DateTime.getFirstDayOfYear(date), DateTime.getLastDayOfYear(date));
107
107
  }
108
108
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.1.53",
3
+ "version": "1.1.54",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"