<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Parth Shah</title>
    <description>The latest articles on DEV Community by Parth Shah (@parth_shah_2a456657c11aad).</description>
    <link>https://dev.to/parth_shah_2a456657c11aad</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1691084%2F8b1170fe-1fe4-4cd3-a1d5-ea780090af9a.jpg</url>
      <title>DEV Community: Parth Shah</title>
      <link>https://dev.to/parth_shah_2a456657c11aad</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/parth_shah_2a456657c11aad"/>
    <language>en</language>
    <item>
      <title>Issue with Date Range Selection and Independent Year selection for Two Calendars in svelte js</title>
      <dc:creator>Parth Shah</dc:creator>
      <pubDate>Thu, 27 Jun 2024 04:31:27 +0000</pubDate>
      <link>https://dev.to/parth_shah_2a456657c11aad/issue-with-date-range-selection-and-independent-year-selection-for-two-calendars-in-svelte-js-1khn</link>
      <guid>https://dev.to/parth_shah_2a456657c11aad/issue-with-date-range-selection-and-independent-year-selection-for-two-calendars-in-svelte-js-1khn</guid>
      <description>&lt;p&gt;I am using Flatpickr in svelte for date range selection in my project and encountered a specific issue regarding the Independent Year selection for two calendars. Currently, when I change the year for one calendar, it changes the year for a second calendar as well. This behavior is not desirable as I need both calendars to update their years independently.&lt;/p&gt;

&lt;p&gt;Expected Behavior:&lt;/p&gt;

&lt;p&gt;Independent Year Updates: Each calendar should allow independent updates to the year without affecting the other calendar. I want to select a range for more than one year like from 2015 to 2018.&lt;/p&gt;

&lt;p&gt;the change year function&lt;/p&gt;

&lt;p&gt;&lt;code&gt;const changeYear = (event: Event, index: number) =&amp;gt; {&lt;br&gt;
    if (calendarInstance) {&lt;br&gt;
      const newYear = parseInt((event.target as HTMLSelectElement).value, 10);&lt;br&gt;
      const currentMonth = (calendarInstance.currentMonth + index) % 12;&lt;br&gt;
      calendarInstance.setDate(new Date(newYear, currentMonth, 1), false);&lt;br&gt;
      updateDropdowns(calendarInstance);&lt;br&gt;
    }&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;the flatepikcer set-up&lt;/p&gt;

&lt;p&gt;`const setupFlatpickr = () =&amp;gt; {&lt;br&gt;
    if (typeof window !== 'undefined') {&lt;br&gt;
      const options = {&lt;br&gt;
        mode: 'range',&lt;br&gt;
        showMonths: 2,&lt;br&gt;
        prevMonthDayClass: 'prevMonthDay not-active',&lt;br&gt;
        defaultDate: [new Date(Date.now() - 7 * 24 * 60 * 60 * 1000), new Date()],&lt;br&gt;
        nextMonthDayClass: 'nextMonthDay not-active',&lt;br&gt;
        dateFormat: 'Y-m-d',&lt;br&gt;
        onChange: (selectedDates: Date[], dateStr: string, instance: FlatpickrInstance) =&amp;gt; {&lt;br&gt;
          startDate = selectedDates[0];&lt;br&gt;
          endDate = selectedDates[1];&lt;br&gt;
          updateSelectedRangeDisplay();&lt;br&gt;
        },&lt;br&gt;
        onReady: (selectedDates: Date[], dateStr: string, instance: FlatpickrInstance) =&amp;gt; {&lt;br&gt;
          calendarInstance = instance;&lt;br&gt;
          insertCustomDropdowns(instance);&lt;br&gt;
          preselectDropdowns(instance);&lt;br&gt;
        },&lt;br&gt;
        onMonthChange: (selectedDates: Date[], dateStr: string, instance: FlatpickrInstance) =&amp;gt; {&lt;br&gt;
          updateDropdowns(instance);&lt;br&gt;
        },&lt;br&gt;
        onYearChange: (selectedDates: Date[], dateStr: string, instance: FlatpickrInstance) =&amp;gt; {&lt;br&gt;
          updateDropdowns(instance);&lt;br&gt;
        },&lt;br&gt;
        onClose: () =&amp;gt; {&lt;br&gt;
          // Handle close event if needed&lt;br&gt;
          isApplied.set(false);&lt;br&gt;
          isCancelled.set(false);&lt;br&gt;
        }&lt;br&gt;
        // Other options as needed&lt;br&gt;
      };&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  flatpickr('#dateRangePicker', options);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;};`&lt;br&gt;
Any Help Would Be Appreciated:&lt;/p&gt;

&lt;p&gt;Your assistance in resolving this issue or providing guidance on how to achieve independent year updates for two Flatpickr calendars would be greatly appreciated. Thank you!&lt;/p&gt;

&lt;p&gt;Git Issue Link:&lt;a href="https://github.com/flatpickr/flatpickr/issues/3025"&gt;https://github.com/flatpickr/flatpickr/issues/3025&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm trying to selecet date range for more then 1 year in svelet js I'm using flate Date picker as of now i'm only abel to selecet range for 1 year&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
