Created
January 29, 2013 14:46
-
-
Save hsjunnesson/4664761 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Block which determine whether two NSDates are on the same day | |
BOOL(^areDatesSameDay)(NSDate *, NSDate *) = ^(NSDate *date1, NSDate *date2) { | |
if (!date1 || !date2) | |
return NO; | |
NSDateComponents *day1 = [[NSCalendar currentCalendar] components:NSEraCalendarUnit|NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:date1]; | |
NSDateComponents *day2 = [[NSCalendar currentCalendar] components:NSEraCalendarUnit|NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:date2]; | |
if ([day1 day] == [day2 day] && | |
[day1 month] == [day2 month] && | |
[day1 year] == [day2 year] && | |
[day1 era] == [day2 era]) { | |
return YES; | |
} | |
return NO; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment