Created
April 23, 2013 07:24
-
-
Save xhinking/5441488 to your computer and use it in GitHub Desktop.
is same day method in obejctive c
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
- (BOOL)isSameDay:(NSDate*)date1 otherDay:(NSDate*)date2 { | |
NSCalendar* calendar = [NSCalendar currentCalendar]; | |
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit; | |
NSDateComponents* comp1 = [calendar components:unitFlags fromDate:date1]; | |
NSDateComponents* comp2 = [calendar components:unitFlags fromDate:date2]; | |
return [comp1 day] == [comp2 day] && | |
[comp1 month] == [comp2 month] && | |
[comp1 year] == [comp2 year]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment