File tree Expand file tree Collapse file tree 5 files changed +42
-7
lines changed Expand file tree Collapse file tree 5 files changed +42
-7
lines changed Original file line number Diff line number Diff line change 3434 };
3535
3636 const toggleDatePicker = () => (isOpen = ! isOpen);
37- const formatDate = (dateString ) => dateString && format (new Date (dateString), dateFormat) || ' ' ;
37+
38+ const formatDate = (dateString ) => {
39+ if (isNaN (new Date (dateString))) {
40+ return ' ' ;
41+ }
42+
43+ return dateString && format (new Date (dateString), dateFormat) || ' ' ;
44+ };
3845
3946 $: formattedStartDate = formatDate (startDate);
4047 $: formattedEndDate = formatDate (endDate);
100107 };
101108
102109 const toggleDatePicker = () => (isOpen = !isOpen);
103- const formatDate = (dateString) => dateString && format(new Date(dateString), dateFormat) || '';
110+
111+ const formatDate = (dateString) => {
112+ if (isNaN(new Date(dateString))) {
113+ return '';
114+ }
115+
116+ return dateString && format(new Date(dateString), dateFormat) || '';
117+ };
104118
105119 $: formattedStartDate = formatDate(startDate);
106120 $: formattedEndDate = formatDate(endDate);
Original file line number Diff line number Diff line change 3636 };
3737
3838 const toggleDatePicker = () => (isOpen = ! isOpen);
39- const formatDate = (dateString ) => dateString && format (new Date (dateString), dateFormat) || ' ' ;
39+
40+ const formatDate = (dateString ) => {
41+ if (isNaN (new Date (dateString))) {
42+ return ' ' ;
43+ }
44+
45+ return dateString && format (new Date (dateString), dateFormat) || ' ' ;
46+ };
4047
4148 $: formattedStartDate = formatDate (startDate);
4249 $: formattedEndDate = formatDate (endDate);
98105 };
99106
100107 const toggleDatePicker = () => (isOpen = !isOpen);
101- const formatDate = (dateString) => dateString && format(new Date(dateString), dateFormat) || '';
108+
109+ const formatDate = (dateString) => {
110+ if (isNaN(new Date(dateString))) {
111+ return '';
112+ }
113+
114+ return dateString && format(new Date(dateString), dateFormat) || '';
115+ };
102116
103117 $: formattedStartDate = formatDate(startDate);
104118 $: formattedEndDate = formatDate(endDate);
Original file line number Diff line number Diff line change 1616 const toggleDatePicker = () => (isOpen = ! isOpen);
1717
1818 const formatDate = (dateString ) => {
19+ if (isNaN (new Date (dateString))) {
20+ return ' ' ;
21+ }
22+
1923 return dateString && format (new Date (dateString), dateFormat) || ' ' ;
2024 };
2125
5357 const toggleDatePicker = () => (isOpen = !isOpen);
5458
5559 const formatDate = (dateString) => {
60+ if (isNaN(new Date(dateString))) {
61+ return '';
62+ }
63+
5664 return dateString && format(new Date(dateString), dateFormat) || '';
5765 };
58-
5966 let formattedStartDate = formatDate(startDate);
6067
6168 const onChange = () => {
Original file line number Diff line number Diff line change 11{
22 "name" : " @svelte-plugins/datepicker" ,
33 "description" : " A simple datepicker component designed for Svelte." ,
4- "version" : " 1.0.9 " ,
4+ "version" : " 1.0.10 " ,
55 "license" : " MIT" ,
66 "author" : " Kieran Boyle (https://github.com/dysfunc)" ,
77 "homepage" : " https://github.com/svelte-plugins/datepicker" ,
You can’t perform that action at this time.
0 commit comments