title: Get current working shift from array with Moment.js
body: Original question
  
  <h3>Get nearest time in the past with Moment.js</h3>
  
  <p><em>Unfortunately the original question wasn't good enough for my use case. However, <a href="https://stackoverflow.com/a/49084165/4530969">M. Mennan Kara's answer</a> is answering exactly to my original question. So you should find it out.</em></p>
  
  <p><strong><em>Improved question with the case example can be found below.</em></strong></p>
  
  <p>Time is now 04:00 (using 24-hour clock). I'd like to parse string <code>22:00:00</code> to Moment.js object.</p>
  
  <pre class="lang-js prettyprint-override"><code>let parsed = moment('22:00:00', 'HH:mm:ss');
  </code></pre>
  
  <p>That worked like a charm. Unlikely the function returns current day by default. So, my question is: <em>isn't it possible to parse to the nearest time in the past?</em></p>
  
  <hr>
  
  Improved question
  
  <h3>Get current working shift from array with Moment.js</h3>
  
  <p>Following is an example case about how it should work in my project. I have working shifts in array and want to save current shift in <code>currentShift</code> variable.</p>
  
  <pre class="lang-js prettyprint-override"><code>let currentShift = null;
  
  let shifts = [
    { name: 'early', start: '06:00:00', end: '14:00:00' },
    { name: 'late',  start: '14:00:00', end: '22:00:00' },
    { name: 'night', start: '22:00:00', end: '06:00:00' }
  ];
  
  shifts.forEach(item =&gt; {
    let start = moment(item.start, 'HH:mm:ss');
    if (moment(item.start, 'HH:mm:ss') &lt;= moment()) {
      currentShift = item;
    }
  });
  </code></pre>