Created
March 10, 2014 08:40
-
-
Save mamaz/9461509 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
// Get string time duration from 2 different NSDate object | |
- (NSString *)getNaturalLanguageForDate:(NSDate *)date1 andDate:(NSDate *)date2 withCalendar:(NSCalendar *)sysCalendar | |
{ | |
// Get conversion to months, days, hours, minutes | |
unsigned int unitFlags = NSHourCalendarUnit | NSMinuteCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit; | |
NSDateComponents *breakdownInfo = [sysCalendar components:unitFlags fromDate:date1 toDate:date2 options:0]; | |
NSString *duration = [NSString stringWithFormat:@"%@:%@", [breakdownInfo hour], [breakdownInfo minute]]; | |
return duration; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment