Swift - check if a timestamp is yesterday, today, tomorrow, or X days ago
I'm trying to work out how to decide if a given timestamp occurs today, or +1 / -1 days. Essentially, I'd like to do something like this (Pseudocode) IF days_from_today(timestamp) == -1 RETURN 'Yesterday' ELSE IF days_from_today(timestamp) == 0 RETURN 'Today' ELSE IF days_from_today(timestamp) == 1 RETURN 'Tomorrow' ELSE IF days_from_today(timestamp) < 1 RETURN days_from_today(timestamp) + ' days ago' ELSE RETURN 'In ' + days_from_today(timestamp) + ' ago' Crucially though, it needs to be in Swift and I'm struggling with the NSDate / NSCalendar objects. I started with working out the time