@hortiview/shared-components 2.22.0 → 2.23.0

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.
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Converts a local date-only value into the persisted UTC representation.
3
+ *
4
+ * Reads the local year/month/day from the provided Date and returns a new Date at
5
+ * 00:00:00.000 UTC for that same calendar day.
6
+ *
7
+ * Example:
8
+ * - User selects "2025-03-15" in their local timezone
9
+ * - Stored value becomes 2025-03-15T00:00:00.000Z
10
+ *
11
+ * This helper is intended for date-only values, not datetime values.
12
+ */
13
+ export declare const convertToUtcFromLocalDate: (date: Date | number) => Date;
14
+ /**
15
+ * Converts the persisted UTC date-only value into a local Date for display in the picker.
16
+ *
17
+ * Reads the UTC year/month/day from the stored value and creates a new local Date with the
18
+ * same visible calendar date.
19
+ *
20
+ * Example:
21
+ * - Stored value is 2025-03-15T00:00:00.000Z
22
+ * - Picker receives a local Date representing "2025-03-15"
23
+ *
24
+ * This helper is intended for date-only values, not datetime values.
25
+ */
26
+ export declare const convertToLocalDateFromUtc: (date: Date | number) => Date;
27
+ /**
28
+ * Returns the corresponding date in a newly selected month or year.
29
+ *
30
+ * Rules:
31
+ * - Preserve the original day-of-month when possible.
32
+ * - If the target month does not contain that day, clamp to the last valid day
33
+ * of the target month.
34
+ *
35
+ * Examples:
36
+ * - 2025-01-15 -> February => 2025-02-15
37
+ * - 2025-01-31 -> February => 2025-02-28
38
+ * - 2025-02-28 -> March => 2025-03-28
39
+ */
40
+ export declare const getSameDayInNextOrPreviousMonth: (currentUtcDate: Date, newMonthOrYearUtcDate: Date) => Date;
@@ -0,0 +1,9 @@
1
+ const g = (t) => t instanceof Date ? new Date(Date.UTC(t.getFullYear(), t.getMonth(), t.getDate())) : new Date(Date.UTC(t)), c = (t) => t instanceof Date ? new Date(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate()) : new Date(t), T = (t, e) => {
2
+ const o = t.getUTCDate(), n = e.getUTCFullYear(), a = e.getUTCMonth(), r = new Date(Date.UTC(n, a + 1, 0)).getUTCDate(), D = Math.min(o, r);
3
+ return new Date(Date.UTC(n, a, D));
4
+ };
5
+ export {
6
+ c as convertToLocalDateFromUtc,
7
+ g as convertToUtcFromLocalDate,
8
+ T as getSameDayInNextOrPreviousMonth
9
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hortiview/shared-components",
3
3
  "description": "This is a shared component library. It should used in the HortiView platform and its modules.",
4
- "version": "2.22.0",
4
+ "version": "2.23.0",
5
5
  "type": "module",
6
6
  "repository": "https://dev.azure.com/sdundc/HV%20Platform/_git/HortiView-Frontend-Shared",
7
7
  "author": "Falk Menge <falk.menge.ext@bayer.com>",