-(NSDate *)beginningOfDay:(NSDate *)date { NSCalendar *cal = [NSCalendar currentCalendar]; NSDateComponents *components = [cal components:( NSMonthCalend
I think the most succinct way to do this in Swift is as follows:
extension Date { func startOfDay() -> Date { return Calendar.current.startOfDay(for: self) } func endOfDay() -> Date { return Calendar.current.date(bySettingHour: 23, minute: 59, second: 59, of: self) ?? self } }