title: A function to parse dates in different arrays of objects
body: <p>I have some arrays defined like this:</p>
  
  <pre><code>const ops = [
    { value: 'YY.00', label: 'Year', type: 'period', info: 'Tax OPS', date: '31.12' }
  ];
  
  const ops1 = [
    { value: 'YY.00', label: 'Year', type: 'period', info: 'Tax OPS 1', date: '01.07', nextYear: 'true' }
  ];
  
  const oms = [
    { value: 'YY.00', label: 'Year', type: 'period', info: 'Tax OMS', date: '31.12' }
  ];
  </code></pre>
  
  <p>I need to parse due dates in three different places through a function <code>getWorkingDay()</code>. The due date consists of a <code>date</code> from an array's object and a <code>year</code> value, which is passed through <code>react-final-form</code> values. If the object has <code>nextYear: 'true'</code>, the <code>year</code> should be incremented by one.</p>
  
  <p>I can get the due date for a single array (for example, <code>ops</code>) like this:</p>
  
  <pre><code>const periodDate = ops.find(item =&gt; item.type === "period").date;
  const [day, month] = periodDate ? periodDate.split(".") : [0, 0];
  const yearFull = '2019';
  const duedate = new Date();
  
  duedate.setDate(Number(day));
  duedate.setMonth(Number(month) - 1);
  duedate.setFullYear(parseInt(yearFull) + 1);
  </code></pre>
  
  <p>And then parse it through <code>getWorkingDay()</code> and <code>format()</code>:</p>
  
  <pre><code>&lt;div&gt;{format(new Date(getWorkingDay(duedate)), 'dd.MM.yyyy')}&lt;/div&gt;
  </code></pre>
  
  <p>My questions are:</p>
  
  <ol>
  <li>How can I create a function to work with all arrays, in which I can pass the name of the array as a parameter?</li>
  <li>How can I pass <code>year</code> value as a second parameter from <code>react-final-form</code> values to this function, instead of hard coding <code>const yearFull = '2019';</code>?</li>
  <li>How can I check <code>nextYear: 'true'</code> from this function to increment the year by one? (<code>duedate.setFullYear</code> should be the year or the year + 1, when <code>nextYear</code> is true)</li>
  <li>Is it better to make <code>date</code> as an object or an array instead of a string to work with this function?</li>
  </ol>