         return nextOpenPeriod
     }
 
-    private func getEarliestOpeningPeriod(fromOpeningPeriods periods: [OpenPeriod]) -> OpenPeriod? {
+    private func getEarliestOpeningPeriod(fromOpeningPeriods periods: [OpenPeriodDates]) -> OpenPeriodDates? {
         return periods.first
     }
 

        }
    }

    private func getCurrentOpeningPeriod(fromOpeningPeriods openingPeriods: [OpenPeriod], forDate date: Date) -> OpenPeriod? {
        let currentPeriods = openingPeriods.filter { isTime(date, duringOpeningPeriod: $0) }
        return currentPeriods.first
    }

    private func getNextOpeningPeriod(fromOpeningPeriods openingPeriods: [OpenPeriod], forDate date: Date) -> OpenPeriod? {
        var nextOpenPeriod: OpenPeriod? = nil
        for openPeriod in openingPeriods {
            if openPeriod.openTime > date {
                guard let currentOpenTime = nextOpenPeriod else {
                    nextOpenPeriod = openPeriod
                    break
                }

                if openPeriod.openTime < currentOpenTime.openTime {
                    nextOpenPeriod = openPeriod
                }
            }

            return false
        }

        if let _ = getCurrentOpeningPeriod(fromOpeningPeriods: allOpeningTimes, forDate: time) {
            return true
        }

        // check to see if the current time is before the earliest open time. If it is, it may be before yesterdays closing time too
        // otherwise we're just not open
        guard let earliestOpeningPeriod = getEarliestOpeningPeriod(fromOpeningPeriods: allOpeningTimes),
            time < earliestOpeningPeriod.openTime,
            let yesterdaysOpeningTimes = getOpeningTimes(forDate: time - AppConstants.ONE_DAY),
            let _ = getCurrentOpeningPeriod(fromOpeningPeriods: yesterdaysOpeningTimes, forDate: time) else {
            return false
        }

        return true
    }

    fileprivate func isTime(_ time: Date, duringOpeningPeriod openingPeriod: OpenPeriodDates) -> Bool {
        return time >= openingPeriod.openTime && time < openingPeriod.closeTime
    }

