turf-common 1.4.2-beta.47 → 1.4.2-beta.49

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.
@@ -37,6 +37,8 @@ export declare class BookingCode {
37
37
  [time: string]: number;
38
38
  };
39
39
  }): number;
40
+ getToDate(): Date;
41
+ isAcrossDate(): boolean;
40
42
  isModificationAllowed(delayInMinutes?: number): boolean;
41
43
  isDeletionAllowed(delayInMinutes?: number): boolean;
42
44
  isCreationAllowed(delayInMinutes?: number): boolean;
@@ -109,9 +109,20 @@ var BookingCode = /** @class */ (function () {
109
109
  }
110
110
  return price;
111
111
  };
112
+ BookingCode.prototype.getToDate = function () {
113
+ return date_util_1.dateUtilService.convertStringToDate(this.getDateWithToTimeCode(), "yyMMddHHmm");
114
+ };
115
+ BookingCode.prototype.isAcrossDate = function () {
116
+ return this.fromTimeCode > this.toTimeCode;
117
+ };
112
118
  BookingCode.prototype.isModificationAllowed = function (delayInMinutes) {
113
119
  if (delayInMinutes === void 0) { delayInMinutes = _utils_1.DEFAULT_BOOKING_MODIFICATION_DELAY_IN_MINUTES; }
114
- var bookingToDateTimeWithDelay = date_util_1.dateUtilService.addMinutesTo(date_util_1.dateUtilService.convertStringToDate(this.getDateWithToTimeCode(), "yyMMddHHmm"), delayInMinutes);
120
+ var dateWithToTimeCode = this.getDateWithToTimeCode();
121
+ // If last four digits of dateWithToTimeCode is 2400, then replace it with 2359
122
+ if (dateWithToTimeCode.slice(-4) === _utils_1.END_OF_DAY_TIME_CODE) {
123
+ dateWithToTimeCode = dateWithToTimeCode.slice(0, -4) + "2359";
124
+ }
125
+ var bookingToDateTimeWithDelay = date_util_1.dateUtilService.addMinutesTo(this.getToDate(), delayInMinutes + (this.isAcrossDate() ? 24 * 60 : 0));
115
126
  var currentTime = date_util_1.dateUtilService.getIndianDate();
116
127
  return bookingToDateTimeWithDelay > currentTime;
117
128
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turf-common",
3
- "version": "1.4.2-beta.47",
3
+ "version": "1.4.2-beta.49",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",