@@ -44,23 +44,8 @@ const DaysMap = {
4444 * If the value is a string, it is parsed into a Date object.
4545 * If the value is null or undefined, null is returned.
4646 * If the parsing fails, null is returned.
47- *
48- * @param value The value to convert.
49- * @returns The converted Date object, or null if the conversion fails.
50- *
51- * @example
52- * ```typescript
53- * const dateString = '2023-11-11T12:34:56Z';
54- * const dateObject = new Date('2023-11-11T12:34:56Z');
55- * const nullValue = null;
56-
57- * const result1 = convertToDate(dateString); // Date object
58- * const result2 = convertToDate(dateObject); // Date object
59- * const result3 = convertToDate(nullValue); // null
60- * const result4 = convertToDate('invalid-date-string'); // null
61- * ```
6247 */
63- export function convertToDate ( value : Date | string | null ) : Date | null {
48+ export function convertToDate ( value ? : Date | string | null ) : Date | null {
6449 if ( ! value ) {
6550 return null ;
6651 }
@@ -74,47 +59,21 @@ export function convertToDate(value: Date | string | null): Date | null {
7459 *
7560 * If the `value` is a `Date` object, it is converted to an ISO 8601 string.
7661 * If the `value` is null or undefined, null is returned.
77- *
78- * @param value The Date object to convert.
79- * @returns The ISO 8601 string representation of the Date object, or null if the value is null or undefined.
80- *
81- * @example
82- * ```typescript
83- * const dateObject = new Date('2023-11-11T12:34:56Z');
84- * const nullValue = null;
85-
86- * const result1 = getDateFormValue(dateObject); // "2023-11-11T12:34:56.000Z"
87- * const result2 = getDateFormValue(nullValue); // null
88- * ```
8962 */
9063export function getDateFormValue ( value : Date | null ) {
9164 return value ? value . toISOString ( ) : null ;
9265}
9366
9467/**
95- * Converts an array of Date objects or a comma-separated string of ISO 8601 dates into an array of Date objects.
96-
97- * If the `value` is an array of `Date` objects, it is returned directly.
98- * If the `value` is a string, it is split by commas and each part is parsed into a `Date` object.
68+ * Converts a comma-separated string of ISO 8601 dates or an array of Date objects | ISO 8601 strings into
69+ * an array of Date objects.
70+ *
9971 * If the `value` is null or undefined, null is returned.
72+ * If the `value` is an array of `Date` objects, a filtered array of valid `Date` objects is returned.
73+ * If the `value` is a string, it is split by commas and each part is parsed into a `Date` object.
10074 * If the parsing fails for any date, it is skipped.
101-
102- * @param value The value to convert.
103- * @returns An array of Date objects, or null if the conversion fails for all values.
104-
105- * @example
106- * ```typescript
107- * const dateStrings = '2023-11-11T12:34:56Z,2023-12-12T13:45:00Z';
108- * const dateObjects = [new Date('2023-11-11T12:34:56Z'), new Date('2023-12-12T13:45:00Z')];
109- * const nullValue = null;
110-
111- * const result1 = convertToDates(dateStrings); // [Date, Date]
112- * const result2 = convertToDates(dateObjects); // [Date, Date]
113- * const result3 = convertToDates(nullValue); // null
114- * const result4 = convertToDates('invalid-date-string,2023-11-11T12:34:56Z'); // [Date]
115- * ```
11675 */
117- export function convertToDates ( value : Date [ ] | string | null ) {
76+ export function convertToDates ( value ?: ( Date | string ) [ ] | string | null ) {
11877 if ( ! value ) {
11978 return null ;
12079 }
@@ -134,7 +93,6 @@ export function convertToDates(value: Date[] | string | null) {
13493
13594/**
13695 * Returns the value of the selected/activated element (day/month/year) in the calendar view.
137- *
13896 */
13997export function getViewElement ( event : Event ) {
14098 const element = findElementFromEventPath < HTMLElement > ( '[data-value]' , event ) ;
0 commit comments