import Foundation extension Calendar { /// Returns `true` if the given date is after today, as defined by the calendar and calendar's locale. /// /// Because it's impossible to define the end of a day (there are an infinite number of /// milliseconds between 23:59:59 and 00:00:00), this method instead ensures that /// `date` >= `startOfTomorrow`. /// /// - parameter date: The specified date. /// - returns: `true` if the given date is after today func isDateAfterToday(_ date: Date) -> Bool { let startOfToday = startOfDay(for: Date()) guard let startOfTomorrow = self.date( byAdding: .day, value: 1, to: startOfToday ) else { return false } switch compare(date, to: startOfTomorrow, toGranularity: .day) { case .orderedSame, .orderedAscending: return false case .orderedDescending: return true } } }