@arsedizioni/ars-utils 22.0.82 → 22.0.83
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/fesm2022/arsedizioni-ars-utils-core.mjs +20 -12
- package/fesm2022/arsedizioni-ars-utils-core.mjs.map +1 -1
- package/package.json +1 -1
- package/types/arsedizioni-ars-utils-clipper.ui.d.ts +1 -1
- package/types/arsedizioni-ars-utils-core.d.ts +9 -5
- package/types/arsedizioni-ars-utils-ui.application.d.ts +2 -2
- package/types/arsedizioni-ars-utils-ui.d.ts +1 -1
|
@@ -1748,22 +1748,30 @@ class SystemUtils {
|
|
|
1748
1748
|
}
|
|
1749
1749
|
}
|
|
1750
1750
|
/**
|
|
1751
|
-
*
|
|
1752
|
-
*
|
|
1753
|
-
*
|
|
1751
|
+
* Converts a Date, timestamp or ISO string into a Europe/Rome Date whose JSON serialisation
|
|
1752
|
+
* emits a naive local datetime string ("yyyy-MM-dd'T'HH:mm:ss"), with no timezone designator,
|
|
1753
|
+
* so the wall-clock value round-trips to the server unchanged. Use this instead of `new Date(...)`
|
|
1754
|
+
* when reviving dates received from the API, to stay consistent with the DateFnsAdapter (values
|
|
1755
|
+
* entered through the datepicker already behave this way).
|
|
1756
|
+
* @param value : the source Date, Unix timestamp (ms) or ISO string
|
|
1757
|
+
* @returns : a Europe/Rome Date serialising as naive local time, or undefined for empty/invalid input
|
|
1754
1758
|
*/
|
|
1755
1759
|
static toLocalDate(value) {
|
|
1756
|
-
|
|
1757
|
-
if (!value)
|
|
1760
|
+
if (value == null || value === '')
|
|
1758
1761
|
return undefined;
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
if (!this.isValidDate(value))
|
|
1762
|
+
const ms = value instanceof Date ? value.getTime()
|
|
1763
|
+
: typeof value === 'number' ? value
|
|
1764
|
+
: new Date(value).getTime();
|
|
1765
|
+
if (isNaN(ms))
|
|
1764
1766
|
return undefined;
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
+
const t = new TZDate(ms, 'Europe/Rome');
|
|
1768
|
+
Object.defineProperty(t, 'toJSON', {
|
|
1769
|
+
value: () => format(t, "yyyy-MM-dd'T'HH:mm:ss"),
|
|
1770
|
+
enumerable: false,
|
|
1771
|
+
configurable: true,
|
|
1772
|
+
writable: true,
|
|
1773
|
+
});
|
|
1774
|
+
return t;
|
|
1767
1775
|
}
|
|
1768
1776
|
/**
|
|
1769
1777
|
* Update a DateInterval object according to a string
|