@molopos/shared 2.0.65 → 2.0.66

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/index.js +6 -5
  2. package/package.json +1 -1
package/date/index.js CHANGED
@@ -167,11 +167,12 @@ const recurrenceDate = ({ date, recurrence, duration = 1, isRecurrence = false,
167
167
  if (!isRecurrence) {
168
168
  return null;
169
169
  }
170
+ const dateInit = date instanceof Date ? date : new Date(date);
170
171
  const dateNowUnix = (0, exports.dateTimeNowUtcUnixInteger)();
171
- const dateUnix = (0, exports.formateDateUnixInteger)(date);
172
+ const dateUnix = (0, exports.formateDateUnixInteger)(dateInit);
172
173
  const isFutureDate = dateUnix > dateNowUnix;
173
174
  const dateNowInit = isFutureDate
174
- ? luxon_1.DateTime.fromJSDate(date)
175
+ ? luxon_1.DateTime.fromJSDate(dateInit)
175
176
  : luxon_1.DateTime.fromJSDate((0, exports.dateTimeNowUtc)());
176
177
  switch (recurrence) {
177
178
  case enum_1.RecurrenceEnum.Daily:
@@ -183,7 +184,7 @@ const recurrenceDate = ({ date, recurrence, duration = 1, isRecurrence = false,
183
184
  return dateNowInit.plus({ months: duration }).toJSDate();
184
185
  }
185
186
  const now = luxon_1.DateTime.fromJSDate((0, exports.dateTimeNowUtc)());
186
- let nextOccurrence = now.set({ day: date.getDate() });
187
+ let nextOccurrence = now.set({ day: dateInit.getDate() });
187
188
  if (nextOccurrence.toUnixInteger() <= dateNowUnix) {
188
189
  nextOccurrence = nextOccurrence.plus({ months: duration });
189
190
  }
@@ -195,8 +196,8 @@ const recurrenceDate = ({ date, recurrence, duration = 1, isRecurrence = false,
195
196
  }
196
197
  const now = luxon_1.DateTime.fromJSDate((0, exports.dateTimeNowUtc)());
197
198
  let nextOccurrence = now.set({
198
- month: date.getMonth() + 1,
199
- day: date.getDate(),
199
+ month: dateInit.getMonth() + 1,
200
+ day: dateInit.getDate(),
200
201
  });
201
202
  if (nextOccurrence.toUnixInteger() <= dateNowUnix) {
202
203
  nextOccurrence = nextOccurrence.plus({ years: duration });
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@molopos/shared","publishConfig":{"access":"public"},"version":"2.0.65","description":"Shared between backend and frontend repos","license":"ISC","repository":{"type":"git","url":"https://github.com/unicubate/molopos-shared.git"},"dependencies":{"class-transformer":"^0.5.1","date-fns":"^4.4.0","luxon":"^3.7.2"}}
1
+ {"name":"@molopos/shared","publishConfig":{"access":"public"},"version":"2.0.66","description":"Shared between backend and frontend repos","license":"ISC","repository":{"type":"git","url":"https://github.com/unicubate/molopos-shared.git"},"dependencies":{"class-transformer":"^0.5.1","date-fns":"^4.4.0","luxon":"^3.7.2"}}