Igor Dorovskikh 31.12.2016 16:28

here is my function to select future or past date:

func getDate(daysFromToday: Int) -> (day : String, month : String){
var components = DateComponents()
components.setValue(daysFromToday, for: .day)

let today = NSDate()
let futureDate = NSCalendar.current.date(byAdding: components, to: today as Date)
let futureDay = NSCalendar.current.component(.day, from: futureDate!)
let futureDayString = String(futureDay)
let futureMonth = NSCalendar.current.component( .month, from: futureDate!)

let dateFormat = DateFormatter()
let futureMonthString = dateFormat.shortMonthSymbols[futureMonth as Int – 1]

return(futureDayString, futureMonthString )
}