My app presenting a list of messages, each has a creation date.
I don't want to just show the date but to show different formats according to how much time passed from the creation date.
for example, this is how I create the date string from the date:
NSDate *date = someMessage.creationDate;
NSTimeInterval timePassed = [[NSDate date] timeIntervalSinceDate:date];
if (timePassed < 60 ) { // less then one minute
return @"now"
} else if (timePassed < 3600) { // less then one hour
NSInteger minutes = (NSInteger) floor(timePassed / 60.0);
return [NSString stringWithFormat:@"%d minutes ago", minutes];
}
so now I want to add the following cases:
else if ("timePassed < 24 hours ago and within the same calendar day")
// do something
} else if ("timePassed > 24 hours, or within previous calendar day") {
// do something else
}
but not sure how to do it, any help will be appreciated