Created
March 27, 2014 12:18
-
-
Save Fogh/9806281 to your computer and use it in GitHub Desktop.
WCF JSON Date to NSDate
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
- (NSDate *)deserializeJsonDateString:(NSString *)jsonDateString | |
{ | |
NSInteger offset = [[NSTimeZone defaultTimeZone] secondsFromGMT]; | |
NSInteger startPosition = [jsonDateString rangeOfString:@"("].location + 1; | |
NSTimeInterval unixTime = [[jsonDateString substringWithRange:NSMakeRange(startPosition, 13)] doubleValue] / 1000; | |
return [[NSDate dateWithTimeIntervalSince1970:unixTime] dateByAddingTimeInterval:offset]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment