     }
 }
 
-
-private extension Date {
-    func isAfterDate(date: Date) -> Bool {
-        return NSDate(timeIntervalSinceNow: self.timeIntervalSinceNow).earlierDate(date) == date
-    }
-
-    func isBeforeDate(date: Date) -> Bool {
-        return NSDate(timeIntervalSinceNow: self.timeIntervalSinceNow).earlierDate(date) == self
-    }
-}
-


        sunriseSet.calculateSunriseSunset(today)

        guard var sunrise = sunriseSet.localSunrise(),
            var sunset = sunriseSet.localSunset(),
            let calendar = NSCalendar(identifier: NSCalendar.Identifier.gregorian) else {
                return self.sunriseSetTimesLabel.text = nil
        }

        sunrise.day = calendar.component(NSCalendar.Unit.day, from: today)
        sunrise.month = calendar.component(NSCalendar.Unit.month, from: today)
        sunrise.year = calendar.component(NSCalendar.Unit.year, from: today)

        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "h:mm a"

        if let sunriseTime = calendar.date(from: sunrise),
            sunriseTime.isAfterDate(date: today) {
            let timeAsString = dateFormatter.string(from: sunriseTime)
            return self.sunriseSetTimesLabel.text = "Sunrise is at \(timeAsString) today"
        }

        sunset.day = calendar.component(NSCalendar.Unit.day, from: today)
        sunset.month = calendar.component(NSCalendar.Unit.month, from: today)
        sunset.year = calendar.component(NSCalendar.Unit.year, from: today)

        if let sunsetTime = calendar.date(from: sunset),
            sunsetTime.isAfterDate(date: today) {
            let timeAsString = dateFormatter.string(from: sunsetTime)
            return self.sunriseSetTimesLabel.text = "Sunset is at \(timeAsString) today"
        }

                }
                once = true
            }

            // if we're running in the simulator, find the timezone of the current coordinates and calculate the sunrise/set times for then
            // this is so that, if we're simulating our location, we still get sunset/sunrise times
            #if (arch(i386) || arch(x86_64))
