this is my code
let dateValue = formatterDate.dateFromString(request.date)
print("da = \(request.date)")
let dayValue = NSDate()
let compnentsDate = myCalendar.components(.Year, fromDate: dateValue!)
let componentsDay = myCalendar.components(.Year, fromDate: dayValue)
if compnentsDate.year == componentsDay.year && compnentsDate.month == componentsDay.month && compnentsDate.day == componentsDay.day {
cell.dateLabel.text = "today"
}else {
if compnentsDate.year == componentsDay.year && compnentsDate.month == componentsDay.month && compnentsDate.day == (componentsDay.day + 1 ){
cell.dateLabel.text = "tomorrow"
}else {
cell.dateLabel.text = request.date
}
}
as you see I am making print, and the value of the print is:
da = Jan, 25, 2016
However, the code always goes to the first if statement, and tell me "today"
why please?
what is wrong in my code?