@chevre/domain 22.9.0-alpha.97 → 22.9.0-alpha.98

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.
@@ -1,21 +1,22 @@
1
1
  // tslint:disable:no-console
2
- import * as moment from 'moment-timezone';
2
+ import * as moment from 'moment';
3
3
 
4
- const importFrom = '2024-04-23T22:45:00.414Z';
5
- const importThrough = '2024-04-25T22:45:00.414Z';
6
- const targetImportFrom = moment(importFrom)
7
- .tz('Asia/Tokyo')
8
- .startOf('day');
9
- const targetImportThrough = moment(importThrough)
10
- .tz('Asia/Tokyo')
11
- .endOf('day');
12
- console.log(targetImportFrom.toDate(), targetImportThrough.toDate());
4
+ const eventStartDate = '2025-04-10T01:00:00Z';
5
+ // const timeFormat = 'HH:mm:ssZ';
6
+ const time = '00:00:00+09:00';
7
+ // const time = '00:00:00Z';
13
8
 
14
- const targetImportFrom2 = moment(`${moment(importFrom)
15
- .tz('Asia/Tokyo')
16
- .format('YYYY-MM-DD')}T00:00:00+09:00`);
17
- const targetImportThrough2 = moment(`${moment(importThrough)
18
- .tz('Asia/Tokyo')
19
- .format('YYYY-MM-DD')}T00:00:00+09:00`)
20
- .add(1, 'day');
21
- console.log(targetImportFrom2.toDate(), targetImportThrough2.toDate());
9
+ // tslint:disable-next-line:no-magic-numbers
10
+ const offset = time.slice(8);
11
+ console.log('offset:', offset);
12
+
13
+ // const opensMoment = moment(time, timeFormat, true);
14
+ // const utcOffset = opensMoment.utcOffset();
15
+
16
+ // const eventStartDateMoment = moment.utc(eventStartDate);
17
+ const eventStartDateMoment = moment(eventStartDate, true);
18
+ console.log(eventStartDateMoment);
19
+ console.log(eventStartDateMoment.utcOffset(offset));
20
+
21
+ const usageDate = moment(`${eventStartDateMoment.format('YYYY-MM-DD')}T${time}`, true);
22
+ console.log(usageDate);
@@ -259,7 +259,7 @@ function validateQuantityRequirement(params) {
259
259
  * 事前予約要件を検証する
260
260
  */
261
261
  function validateAdvanceBookingRequirement(params) {
262
- var _a;
262
+ var _a, _b;
263
263
  let requirementSatisfied = true;
264
264
  // reimplement using advanceBookingRequirementRepo(2025-04-08~)
265
265
  const advanceBookingRequirementId = (_a = params.unitPriceOffer.advanceBookingRequirement) === null || _a === void 0 ? void 0 : _a.id;
@@ -271,7 +271,18 @@ function validateAdvanceBookingRequirement(params) {
271
271
  const advanceBookingRequirementMaxValue = advanceBookingRequirement.maxValue;
272
272
  const advanceBookingRequirementMinValue = advanceBookingRequirement.minValue;
273
273
  const advanceBookingRequirementUnitCode = advanceBookingRequirement.unitCode;
274
- const usageDate = moment(params.reservationFor.startDate);
274
+ const valueReferenceOpens = (_b = advanceBookingRequirement.valueReference) === null || _b === void 0 ? void 0 : _b.opens;
275
+ let usageDate = moment(params.reservationFor.startDate, true);
276
+ if (typeof valueReferenceOpens === 'string') {
277
+ // support valueReference(2025-04-10~)
278
+ // tslint:disable-next-line:no-magic-numbers
279
+ const opensOffset = valueReferenceOpens.slice(8); // format: HH:mm:ssZ
280
+ // tslint:disable-next-line:no-console
281
+ debug('opensOffset:', opensOffset);
282
+ usageDate = usageDate.utcOffset(opensOffset);
283
+ usageDate = moment(`${usageDate.format('YYYY-MM-DD')}T${valueReferenceOpens}`, true);
284
+ }
285
+ debug('usageDate:', usageDate);
275
286
  if (typeof advanceBookingRequirementMaxValue === 'number' && typeof advanceBookingRequirementUnitCode === 'string') {
276
287
  if (advanceBookingRequirementMaxValue < 0) {
277
288
  throw new factory.errors.NotImplemented('negative value as advanceBookingRequirement.maxValue not implemented');
@@ -280,7 +291,7 @@ function validateAdvanceBookingRequirement(params) {
280
291
  throw new factory.errors.NotImplemented(`only ${factory.unitCode.Day} implemented`);
281
292
  }
282
293
  const usageDateMustBeBefore = moment(params.now)
283
- .add(advanceBookingRequirementMinValue, 'days');
294
+ .add(advanceBookingRequirementMaxValue, 'days');
284
295
  if (!usageDate.isSameOrBefore(usageDateMustBeBefore)) {
285
296
  requirementSatisfied = false;
286
297
  }
@@ -31,8 +31,6 @@ function wait4payActionDelayIfNeeded(params) {
31
31
  }
32
32
  }
33
33
  if (waitingNecessary) {
34
- // tslint:disable-next-line:no-console
35
- console.log('wait4payActionDelayIfNeeded: waiting... minIntervalBetweenPayAndRefund:', minIntervalBetweenPayAndRefund);
36
34
  yield new Promise((resolve) => {
37
35
  setTimeout(() => {
38
36
  resolve();
package/package.json CHANGED
@@ -113,5 +113,5 @@
113
113
  "postversion": "git push origin --tags",
114
114
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
115
115
  },
116
- "version": "22.9.0-alpha.97"
116
+ "version": "22.9.0-alpha.98"
117
117
  }