turf-common 1.2.1-beta.73 → 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.
@@ -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
- var timeCode = timeFormatter.timeCode, timeFormat = timeFormatter.timeFormat;
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;
@@ -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
  *
@@ -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
- if (toDateCode.slice(-4, -2) === "24") {
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
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turf-common",
3
- "version": "1.2.1-beta.73",
3
+ "version": "1.2.1-beta.74",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",