I want to keep date/times in a CoreData store with no seconds or milliseconds. (I'm doing some processing to round times off, and stray seconds/milliseconds become a monkey wrench.) It's easy enough to drop the seconds:
NSDate *now = [NSDate date];
NSDateComponents *time = [[NSCalendar currentCalendar]
components:NSHourCalendarUnit | NSMinuteCalendarUnit
| NSSecondCalendarUnit fromDate:now];
NSDate *nowMinus = [now addTimeInterval:-time.second];
// e.g. 29 Aug 10 4:43:05 -> 29 Aug 10 4:43:00
This works great to zero out the seconds, but I can't find an NSMillisecondCalendarUnit I could use to zero out the milliseconds, and I need to. Any ideas? Thanks.