Created
August 7, 2014 10:33
-
-
Save maxehmookau/859ce516dd92d93f246b to your computer and use it in GitHub Desktop.
Convert military time to NSDate (NSNumber Category)
This file contains hidden or 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
- (NSDate *)sub_DateFromMilitaryTime { | |
NSDate *newDate; | |
NSDateComponents *comps = [[NSDateComponents alloc] init]; | |
[comps setMinute:[self intValue] % 100]; | |
[comps setHour:floor(self.intValue / 100)]; | |
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; | |
newDate = [gregorian dateFromComponents:comps]; | |
return newDate; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment