@adobe/spacecat-shared-utils 1.12.2 → 1.12.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [@adobe/spacecat-shared-utils-v1.12.3](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.12.2...@adobe/spacecat-shared-utils-v1.12.3) (2024-02-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * enhance dateAfterDays ([189895a](https://github.com/adobe/spacecat-shared/commit/189895acc254703ae90bdebb965346ffe39350c3))
7
+
1
8
  # [@adobe/spacecat-shared-utils-v1.12.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.12.1...@adobe/spacecat-shared-utils-v1.12.2) (2024-02-27)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-utils",
3
- "version": "1.12.2",
3
+ "version": "1.12.3",
4
4
  "description": "Shared modules of the Spacecat Services - utils",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/functions.js CHANGED
@@ -169,6 +169,7 @@ const arrayEquals = (a, b) => isArray(a)
169
169
  * Calculates the date after a specified number of days from the current date.
170
170
  *
171
171
  * @param {number} days - The number of days to add to the current date.
172
+ * @param {string=} dateString - The reference date in string format.
172
173
  * @returns {Date} A new Date object representing the calculated date after the specified days.
173
174
  * @throws {TypeError} If the provided 'days' parameter is not a number.
174
175
  * @throws {RangeError} If the calculated date is outside the valid JavaScript date range.
@@ -178,9 +179,9 @@ const arrayEquals = (a, b) => isArray(a)
178
179
  * const sevenDaysLater = dateAfterDays(7);
179
180
  * console.log(sevenDaysLater); // Outputs a Date object representing the date 7 days from now
180
181
  */
181
- function dateAfterDays(days) {
182
- const currentDate = new Date();
183
- currentDate.setDate(currentDate.getDate() + days);
182
+ function dateAfterDays(days, dateString) {
183
+ const currentDate = !dateString ? new Date() : new Date(dateString);
184
+ currentDate.setUTCDate(currentDate.getDate() + days);
184
185
  return currentDate;
185
186
  }
186
187
 
package/src/index.d.ts CHANGED
@@ -35,7 +35,7 @@ export function toBoolean(value: unknown): boolean;
35
35
 
36
36
  export function isValidUrl(urlString: string): boolean;
37
37
 
38
- export function dateAfterDays(days: number): Date;
38
+ export function dateAfterDays(days: number, dateString: string): Date;
39
39
 
40
40
  export function sqsWrapper(fn: (message: object, context: object) => Promise<Response>):
41
41
  (request: object, context: object) => Promise<Response>;