@unikue/ts-lang-utils 1.2.2 → 1.2.3

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.
@@ -26,8 +26,12 @@ function addMonth(date, amount) {
26
26
  if (!date || !amount) {
27
27
  return date;
28
28
  }
29
+ const day = date.getDate();
29
30
  const result = new Date(date);
30
31
  result.setMonth(date.getMonth() + amount);
32
+ if (result.getDate() !== day) {
33
+ result.setDate(0);
34
+ }
31
35
  return result;
32
36
  }
33
37
  // Annotate the CommonJS export names for ESM import in node:
@@ -26,8 +26,12 @@ function addYear(date, amount) {
26
26
  if (!date || !amount) {
27
27
  return date;
28
28
  }
29
+ const day = date.getDate();
29
30
  const result = new Date(date);
30
31
  result.setFullYear(date.getFullYear() + amount);
32
+ if (result.getDate() !== day) {
33
+ result.setDate(0);
34
+ }
31
35
  return result;
32
36
  }
33
37
  // Annotate the CommonJS export names for ESM import in node:
@@ -2,7 +2,11 @@ export function addMonth(date, amount) {
2
2
  if (!date || !amount) {
3
3
  return date;
4
4
  }
5
+ var day = date.getDate();
5
6
  var result = new Date(date);
6
7
  result.setMonth(date.getMonth() + amount);
8
+ if (result.getDate() !== day) {
9
+ result.setDate(0);
10
+ }
7
11
  return result;
8
12
  }
@@ -2,7 +2,11 @@ export function addYear(date, amount) {
2
2
  if (!date || !amount) {
3
3
  return date;
4
4
  }
5
+ var day = date.getDate();
5
6
  var result = new Date(date);
6
7
  result.setFullYear(date.getFullYear() + amount);
8
+ if (result.getDate() !== day) {
9
+ result.setDate(0);
10
+ }
7
11
  return result;
8
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unikue/ts-lang-utils",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "title": "TsLangUtils",
5
5
  "description": "Common lang utilities for typescript",
6
6
  "homepage": "https://unikueltd.github.io/ts-lang-utils",