turf-common 1.2.1-beta.72 → 1.2.1-beta.74
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.
|
@@ -113,4 +113,11 @@ export declare class BookingCode {
|
|
|
113
113
|
toDateCode: string;
|
|
114
114
|
};
|
|
115
115
|
static getTotalTimeByBookingCodes(bookingCodes: BookingCode[]): number;
|
|
116
|
+
/**
|
|
117
|
+
* Retrieves booking codes for a booking scenario that may span across different days.
|
|
118
|
+
* If the booking spans multiple days, two codes are generated for each day; otherwise, a single code is used.
|
|
119
|
+
*
|
|
120
|
+
* @returns {string[]} An array containing the booking codes.
|
|
121
|
+
*/
|
|
122
|
+
getBookingCodesByAcrossDateBookingCode(): string[];
|
|
116
123
|
}
|
|
@@ -501,6 +501,7 @@ var BookingCode = /** @class */ (function () {
|
|
|
501
501
|
};
|
|
502
502
|
BookingCode.prototype.formatDateAndTime = function (formateDateAndTime) {
|
|
503
503
|
var dateFormat = formateDateAndTime.dateFormat, timeFormat = formateDateAndTime.timeFormat, separator = formateDateAndTime.separator, timeSeparator = formateDateAndTime.timeSeparator;
|
|
504
|
+
this.toTimeCode = date_util_1.dateUtilService.handle2400HourInDateCode(this.toTimeCode);
|
|
504
505
|
var formattedDate = BookingCode.dateFormatter({
|
|
505
506
|
dateFormat: dateFormat,
|
|
506
507
|
dateCode: this.dateCode,
|
|
@@ -516,9 +517,9 @@ var BookingCode = /** @class */ (function () {
|
|
|
516
517
|
return "".concat(formattedDate).concat(separator).concat(formattedFromTime).concat(timeSeparator).concat(formattedToTime);
|
|
517
518
|
};
|
|
518
519
|
BookingCode.timeFormatter = function (timeFormatter) {
|
|
519
|
-
|
|
520
|
-
var parsedFromTime = (0, date_fns_1.parse)(timeCode, "HHmm", new Date());
|
|
521
|
-
return (0, date_fns_1.format)(parsedFromTime, timeFormat);
|
|
520
|
+
timeFormatter.timeCode = date_util_1.dateUtilService.handle2400HourInDateCode(timeFormatter.timeCode);
|
|
521
|
+
var parsedFromTime = (0, date_fns_1.parse)(timeFormatter.timeCode, "HHmm", new Date());
|
|
522
|
+
return (0, date_fns_1.format)(parsedFromTime, timeFormatter.timeFormat);
|
|
522
523
|
};
|
|
523
524
|
BookingCode.dateFormatter = function (dateFormatter) {
|
|
524
525
|
var dateFormat = dateFormatter.dateFormat, dateCode = dateFormatter.dateCode;
|
|
@@ -556,6 +557,26 @@ var BookingCode = /** @class */ (function () {
|
|
|
556
557
|
});
|
|
557
558
|
return totalBookingHours;
|
|
558
559
|
};
|
|
560
|
+
/**
|
|
561
|
+
* Retrieves booking codes for a booking scenario that may span across different days.
|
|
562
|
+
* If the booking spans multiple days, two codes are generated for each day; otherwise, a single code is used.
|
|
563
|
+
*
|
|
564
|
+
* @returns {string[]} An array containing the booking codes.
|
|
565
|
+
*/
|
|
566
|
+
BookingCode.prototype.getBookingCodesByAcrossDateBookingCode = function () {
|
|
567
|
+
var bookingCodes = [];
|
|
568
|
+
// Check if the booking spans across different days
|
|
569
|
+
if (this.fromTimeCode > this.toTimeCode) {
|
|
570
|
+
var firstDayCode = "".concat(this.turfId).concat(this.dateCode).concat(this.fromTimeCode, "2400").concat(this.pitchCode);
|
|
571
|
+
var secondDayCode = "".concat(this.turfId).concat(date_util_1.dateUtilService.addNDaysToDateCode(this.dateCode, 1), "0000").concat(this.toTimeCode).concat(this.pitchCode);
|
|
572
|
+
bookingCodes.push(firstDayCode);
|
|
573
|
+
bookingCodes.push(secondDayCode);
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
bookingCodes.push(this.code);
|
|
577
|
+
}
|
|
578
|
+
return bookingCodes;
|
|
579
|
+
};
|
|
559
580
|
/**
|
|
560
581
|
* Extracts the numeric part of a bookingCode, excluding a predefined deleted slot separator.
|
|
561
582
|
*
|
|
@@ -14,6 +14,13 @@ export declare class DateUtilService {
|
|
|
14
14
|
formatDateCode(dateCode: string): string;
|
|
15
15
|
getDateNDaysFromToday(n: number): Date;
|
|
16
16
|
calculateDateDifference(fromDateCode: string, toDateCode: string, unit?: "minute" | "hr"): number;
|
|
17
|
+
/**
|
|
18
|
+
* Handles the special case when the hours and minutes portion of the date code is set to "2400" by adjusting to the next day.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} dateCode - The original date code.
|
|
21
|
+
* @returns {string} The adjusted date code.
|
|
22
|
+
*/
|
|
23
|
+
handle2400HourInDateCode(toDateCode: string): string;
|
|
17
24
|
/**
|
|
18
25
|
* Adds or subtracts a specified number of months from a given date in YYMM format.
|
|
19
26
|
*
|
package/build/utils/date-util.js
CHANGED
|
@@ -76,12 +76,7 @@ var DateUtilService = /** @class */ (function () {
|
|
|
76
76
|
};
|
|
77
77
|
DateUtilService.prototype.calculateDateDifference = function (fromDateCode, toDateCode, unit) {
|
|
78
78
|
if (unit === void 0) { unit = "minute"; }
|
|
79
|
-
|
|
80
|
-
toDateCode =
|
|
81
|
-
exports.dateUtilService.addNDaysToDateCode(toDateCode.slice(0, -4), 1) +
|
|
82
|
-
"00" +
|
|
83
|
-
toDateCode.slice(-2);
|
|
84
|
-
}
|
|
79
|
+
toDateCode = this.handle2400HourInDateCode(toDateCode);
|
|
85
80
|
var fromDate = (0, date_fns_1.parse)(fromDateCode, "yyMMddHHmm", new Date());
|
|
86
81
|
var toDate = (0, date_fns_1.parse)(toDateCode, "yyMMddHHmm", new Date());
|
|
87
82
|
var minutesDifference = (0, date_fns_1.differenceInMinutes)(toDate, fromDate);
|
|
@@ -89,6 +84,21 @@ var DateUtilService = /** @class */ (function () {
|
|
|
89
84
|
? minutesDifference
|
|
90
85
|
: parseFloat((minutesDifference / 60).toFixed(1));
|
|
91
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* Handles the special case when the hours and minutes portion of the date code is set to "2400" by adjusting to the next day.
|
|
89
|
+
*
|
|
90
|
+
* @param {string} dateCode - The original date code.
|
|
91
|
+
* @returns {string} The adjusted date code.
|
|
92
|
+
*/
|
|
93
|
+
DateUtilService.prototype.handle2400HourInDateCode = function (toDateCode) {
|
|
94
|
+
if (toDateCode.slice(-4, -2) === "24") {
|
|
95
|
+
toDateCode =
|
|
96
|
+
exports.dateUtilService.addNDaysToDateCode(toDateCode.slice(0, -4), 1) +
|
|
97
|
+
"00" +
|
|
98
|
+
toDateCode.slice(-2);
|
|
99
|
+
}
|
|
100
|
+
return toDateCode;
|
|
101
|
+
};
|
|
92
102
|
/**
|
|
93
103
|
* Adds or subtracts a specified number of months from a given date in YYMM format.
|
|
94
104
|
*
|