Created
August 14, 2015 17:40
-
-
Save DonMag/0b2f27ffdfef2a676220 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
// compare Time - Hour Minute Second - between two dates, ignoring the date part | |
- (BOOL)isTime:(NSDate *)d1 equalTo:(NSDate *)d2 { | |
unsigned int flags = NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond; | |
NSCalendar* calendar = [NSCalendar currentCalendar]; | |
NSDateComponents* components1 = [calendar components:flags fromDate:d1]; | |
NSDateComponents* components2 = [calendar components:flags fromDate:d2]; | |
NSDate* timeOnly1 = [calendar dateFromComponents:components1]; | |
NSDate* timeOnly2 = [calendar dateFromComponents:components2]; | |
return [timeOnly1 isEqualToDate:timeOnly2]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment