Created
February 11, 2013 01:30
-
-
Save codingrhythm/4751879 to your computer and use it in GitHub Desktop.
Objective-C class that converts standard ISO date string to NSDate object
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+ISOSupport.h | |
// | |
// Created by Zhu Yuzhou on 1/12/13. | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSDate (ISOSupport) | |
+(NSDate *)dateWithISOString:(NSString *)dateString; | |
@end |
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+ISOSupport.m | |
// | |
// Created by Zhu Yuzhou on 1/12/13. | |
// | |
#import "NSDate+ISOSupport.h" | |
@implementation NSDate (ISOSupport) | |
+(NSDate *)dateWithISOString:(NSString *)dateString | |
{ | |
dateString = [dateString stringByReplacingOccurrencesOfString:@":" withString:@""]; | |
NSDateFormatter *f = [[NSDateFormatter alloc] init]; | |
[f setDateFormat:@"yyyy-MM-dd'T'HHmmss.SSSSSSZZ"]; | |
return [f dateFromString:dateString]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment