turf-common 1.2.1-beta.56 → 1.2.1-beta.58

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.
@@ -50,7 +50,7 @@ export declare class TurfAvailability implements ITurfAvailability {
50
50
  endDateCode: string;
51
51
  fromTimeCode: string;
52
52
  toTimeCode: string;
53
- weekDays: number[];
53
+ bookingDateCodes: string[];
54
54
  };
55
55
  }
56
56
  export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TurfAvailability = void 0;
4
+ var _utils_1 = require("../@utils");
4
5
  var booking_code_model_1 = require("./booking-code-model");
5
6
  var TurfAvailability = /** @class */ (function () {
6
7
  function TurfAvailability(data) {
@@ -193,13 +194,17 @@ var TurfAvailability = /** @class */ (function () {
193
194
  var eventCodes = eventCode.split("#");
194
195
  var dateCodeRange = eventCodes[1];
195
196
  var timeCodeRange = eventCodes[2];
197
+ var weekDays = ((_a = eventCodes[4]) === null || _a === void 0 ? void 0 : _a.split(",").map(Number)) || -1;
198
+ var startDateCode = dateCodeRange.slice(0, 6);
199
+ var endDateCode = dateCodeRange.slice(6, 12);
200
+ var bookingDateCodes = _utils_1.dateUtilService.getBookingCodeByWeekDaysAndDateRange(startDateCode, endDateCode, weekDays);
196
201
  return {
197
202
  pitchCodes: eventCodes[3].split(",").map(function (id) { return id.padStart(2, "0"); }),
198
- startDateCode: dateCodeRange.slice(0, 6),
199
- endDateCode: dateCodeRange.slice(6, 12),
203
+ startDateCode: startDateCode,
204
+ endDateCode: endDateCode,
200
205
  fromTimeCode: timeCodeRange.slice(0, 4),
201
206
  toTimeCode: timeCodeRange.slice(4, 8),
202
- weekDays: ((_a = eventCodes[4]) === null || _a === void 0 ? void 0 : _a.split(",").map(Number)) || -1,
207
+ bookingDateCodes: bookingDateCodes,
203
208
  };
204
209
  };
205
210
  return TurfAvailability;
@@ -35,5 +35,14 @@ export declare class DateUtilService {
35
35
  getMonthRangeByDateCodes(startDateCode: string, endDateCode: string): number[];
36
36
  convertToMidnight(time: IConvertToMidNightTime): IConvertToMidNightTime;
37
37
  convertMonthsToNumber: (months: INgbDateStruct) => string;
38
+ /**
39
+ * Retrieves booking date codes for a specified date range and weekdays.
40
+ *
41
+ * @param startDateCode - The starting date code for the date range.
42
+ * @param endDateCode - The ending date code for the date range.
43
+ * @param weekdays - An array of numbers representing weekdays (1 for Monday through 7 for Sunday).
44
+ * @returns An array of booking date codes based on the provided date range and weekdays.
45
+ */
46
+ getBookingCodeByWeekDaysAndDateRange(startDateCode: string, endDateCode: string, weekdays: number[]): string[];
38
47
  }
39
48
  export declare const dateUtilService: DateUtilService;
@@ -121,6 +121,23 @@ var DateUtilService = /** @class */ (function () {
121
121
  return { hour: 24, minute: 0 };
122
122
  return time;
123
123
  };
124
+ /**
125
+ * Retrieves booking date codes for a specified date range and weekdays.
126
+ *
127
+ * @param startDateCode - The starting date code for the date range.
128
+ * @param endDateCode - The ending date code for the date range.
129
+ * @param weekdays - An array of numbers representing weekdays (1 for Monday through 7 for Sunday).
130
+ * @returns An array of booking date codes based on the provided date range and weekdays.
131
+ */
132
+ DateUtilService.prototype.getBookingCodeByWeekDaysAndDateRange = function (startDateCode, endDateCode, weekdays) {
133
+ var bookingDateCodes = [];
134
+ weekdays.forEach(function (weekDay) {
135
+ var startDateCodeCopy = Number(startDateCode);
136
+ var endDateCodeCopy = Number(endDateCode);
137
+ bookingDateCodes.push.apply(bookingDateCodes, _model_1.BookingCode.getDateCodesByWeek(startDateCodeCopy, endDateCodeCopy, weekDay));
138
+ });
139
+ return bookingDateCodes.map(Number).sort().map(String);
140
+ };
124
141
  return DateUtilService;
125
142
  }());
126
143
  exports.DateUtilService = DateUtilService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turf-common",
3
- "version": "1.2.1-beta.56",
3
+ "version": "1.2.1-beta.58",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",