I need to display a date and, if it’s not representing midnight, the time of that date using an NSDateFormatter. This is how I’m currently checking to see if it’s midnight:
int minute = [[CalendarUtil cal]ordinalityOfUnit:NSMinuteCalendarUnit
inUnit:NSDayCalendarUnit forDate:date];
if (minute == 1) {
//time is midnight
}
[CalendarUtil cal] returns a static object, and no dates have time more specific than minutes (that is, it will always be on the minute, +- 0 seconds).
Is there any more practical or faster method to determine this?
NSDateis toll-free bridged to CFDateRef, and you can use that to get more useable information about the date. You could do something like this:Whether that’s faster or more practical, I don’t know.