@hestia-earth/utils 0.13.19 → 0.13.20

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.
package/dist/date.d.ts CHANGED
@@ -20,6 +20,15 @@ export declare const diffInDays: (date1: Date | string, date2: Date | string) =>
20
20
  * @returns The difference between date1 and date2 in years (precision: 1).
21
21
  */
22
22
  export declare const diffInYears: (date1: Date | string, date2: Date | string) => number;
23
+ /**
24
+ * Remove months on the date.
25
+ *
26
+ * @param date The date.
27
+ * @param days How many months to remove. Note: you can use a negative number to add months.
28
+ *
29
+ * @returns New date.
30
+ */
31
+ export declare const monthsBefore: (date?: Date, months?: number) => Date;
23
32
  /**
24
33
  * Remove days on the date.
25
34
  *
package/dist/date.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.minutesBefore = exports.hoursBefore = exports.daysBefore = exports.diffInYears = exports.diffInDays = exports.dayMs = exports.hourMs = exports.minuteMs = exports.secondMs = void 0;
3
+ exports.minutesBefore = exports.hoursBefore = exports.daysBefore = exports.monthsBefore = exports.diffInYears = exports.diffInDays = exports.dayMs = exports.hourMs = exports.minuteMs = exports.secondMs = void 0;
4
4
  exports.secondMs = 1000;
5
5
  exports.minuteMs = 60 * exports.secondMs;
6
6
  exports.hourMs = 60 * exports.minuteMs;
@@ -30,6 +30,22 @@ var diffInYears = function (date1, date2) {
30
30
  return Math.round((exports.diffInDays(date1, date2) / year) * 10) / 10;
31
31
  };
32
32
  exports.diffInYears = diffInYears;
33
+ /**
34
+ * Remove months on the date.
35
+ *
36
+ * @param date The date.
37
+ * @param days How many months to remove. Note: you can use a negative number to add months.
38
+ *
39
+ * @returns New date.
40
+ */
41
+ var monthsBefore = function (date, months) {
42
+ if (date === void 0) { date = new Date(); }
43
+ if (months === void 0) { months = 1; }
44
+ var newDate = new Date(date);
45
+ newDate.setMonth(new Date().getMonth() - months);
46
+ return newDate;
47
+ };
48
+ exports.monthsBefore = monthsBefore;
33
49
  /**
34
50
  * Remove days on the date.
35
51
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hestia-earth/utils",
3
- "version": "0.13.19",
3
+ "version": "0.13.20",
4
4
  "description": "HESTIA Utils library",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",