title: Check if current time is between range of times considering after midnight - Swift
body: <p>I have an opening and closing hours of restaurants from rest service:</p>
  
  <pre><code>[
     {
        "weekday":0,
        "openingAt":"07:30:00",
        "closingAt":"00:45:00"
     },
     {
        "weekday":1,
        "openingAt":"07:30:00",
        "closingAt":"23:00:00"
     },
     {
        "weekday":2,
        "openingAt":"07:30:00",
        "closingAt":"23:00:00"
     },
     {
        "weekday":3,
        "openingAt":"07:30:00",
        "closingAt":"23:00:00"
     },
     {
        "weekday":4,
        "openingAt":"07:30:00",
        "closingAt":"23:00:00"
     },
     {
        "weekday":5,
        "openingAt":"07:30:00",
        "closingAt":"23:00:00"
     },
     {
        "weekday":6,
        "openingAt":"07:30:00",
        "closingAt":"01:00:00"
     }
  ]
  </code></pre>
  
  <p>I have created computed property for a check that:</p>
  
  <pre><code>var isClosed: Bool {
      let todayIndex = (Calendar.current.component(.weekday, from: Date()) - 1) % 7
      let yesterdayIndex = (Calendar.current.component(.weekday, from: Date()) - 2) % 7
  
      let todayDate = Date()
      if let wh = workingHour, wh.count &gt; 7 {
          let todayWh = wh[todayIndex]
          if let openingStr = todayWh.openingAt, openingStr != "",
              let openingDate = Date().setTimeHHmmss(formattedString: openingStr),
              let closingStr = todayWh.closingAt, closingStr != "",
              let closingDate = Date().setTimeHHmmss(formattedString: closingStr)
          {
              let yesterdayWh = wh[yesterdayIndex]
              var fromYesterdayExtraHours = 0
              if let yesterdayClosingStr = yesterdayWh.closingAt,
                  let yClosingDate = Date().setTimeHHmmss(formattedString: yesterdayClosingStr) {
                  if yClosingDate.hour &gt; 0 {
                      fromYesterdayExtraHours = yClosingDate.hour
                  }
              }
              if  closingDate &lt; openingDate {
                  if todayDate.hour &lt; fromYesterdayExtraHours {
                      return false // opened
                  } else {
                      return true // closed
                  }
              } else if todayDate &gt;= openingDate &amp;&amp; todayDate &lt;= closingDate {
                  return false // opened
              } else {
                  return true // closed
              }
          }
      }
      return false // opened
  }
  </code></pre>
  
  <p>What I do is:</p>
  
  <ol>
  <li>Converting the strings to date object by setting the time on today object</li>
  <li>Then checking if the closing time is on the next day (the worst part)</li>
  <li>Then checking if the closing time is less than opening time, (like this: <code>"openingAt":"07:30:00", "closingAt":"01:00:00"</code> </li>
  <li>Then checking if the current time is between opening and closing time</li>
  </ol>
  
  <p>Any Swifty way suggestion to fix this mess?</p>