turf-common 1.2.1-beta.28 → 1.2.1-beta.29

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.
@@ -13,5 +13,14 @@ export declare class DateUtilService {
13
13
  formatDateCode(dateCode: string): string;
14
14
  getDateNDaysFromToday(n: number): Date;
15
15
  calculateDateDifference(fromDateCode: string, toDateCode: string, unit?: "minute" | "hr"): number;
16
+ /**
17
+ * Adds or subtracts a specified number of months from a given date in YYMMDD format.
18
+ *
19
+ * @param {string} dateCode - A string representing a date in YYMMDD format.
20
+ * @param {number} N - An integer representing the number of months to add or subtract.
21
+ * Use a positive value to add months and a negative value to subtract months.
22
+ * @returns {string} A string representing the resulting date in YYMM format.
23
+ */
24
+ addNMonth(dateCode: string, N: number): string;
16
25
  }
17
26
  export declare const dateUtilService: DateUtilService;
@@ -78,6 +78,19 @@ var DateUtilService = /** @class */ (function () {
78
78
  ? minutesDifference
79
79
  : parseFloat((minutesDifference / 60).toFixed(1));
80
80
  };
81
+ /**
82
+ * Adds or subtracts a specified number of months from a given date in YYMMDD format.
83
+ *
84
+ * @param {string} dateCode - A string representing a date in YYMMDD format.
85
+ * @param {number} N - An integer representing the number of months to add or subtract.
86
+ * Use a positive value to add months and a negative value to subtract months.
87
+ * @returns {string} A string representing the resulting date in YYMM format.
88
+ */
89
+ DateUtilService.prototype.addNMonth = function (dateCode, N) {
90
+ var date = (0, date_fns_1.parse)("20".concat(dateCode), "yyyyMMdd", new Date());
91
+ var resultDate = N >= 0 ? (0, date_fns_1.addMonths)(date, N) : (0, date_fns_1.subMonths)(date, Math.abs(N));
92
+ return (0, date_fns_1.format)(resultDate, "yyMM");
93
+ };
81
94
  return DateUtilService;
82
95
  }());
83
96
  exports.DateUtilService = DateUtilService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turf-common",
3
- "version": "1.2.1-beta.28",
3
+ "version": "1.2.1-beta.29",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",