Skip to content

Commit

Permalink
Give formatters unique names
Browse files Browse the repository at this point in the history
  • Loading branch information
jalmaas-agens committed Mar 19, 2014
1 parent 24355b9 commit 0366f94
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions JSONModel/JSONModelTransformations/JSONValueTransformer.m
Original file line number Diff line number Diff line change
Expand Up @@ -207,28 +207,28 @@ -(NSString*)JSONObjectFromNSURL:(NSURL*)url
#pragma mark - string <-> date
-(NSDate*)__NSDateFromNSString:(NSString*)string
{
static NSDateFormatter *dateFormatter;
static NSDateFormatter *dateFormatterString;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HHmmssZZZZ"];
dateFormatterString = [[NSDateFormatter alloc] init];
[dateFormatterString setDateFormat:@"yyyy-MM-dd'T'HHmmssZZZZ"];
});

string = [string stringByReplacingOccurrencesOfString:@":" withString:@""]; // this is such an ugly code, is this the only way?

return [dateFormatter dateFromString: string];
return [dateFormatterString dateFromString: string];
}

-(NSString*)__JSONObjectFromNSDate:(NSDate*)date
{
static NSDateFormatter *dateFormatter;
static NSDateFormatter *dateFormatterJSON;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZ"];
dateFormatterJSON = [[NSDateFormatter alloc] init];
[dateFormatterJSON setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZ"];
});

return [dateFormatter stringFromDate:date];
return [dateFormatterJSON stringFromDate:date];
}

@end

0 comments on commit 0366f94

Please sign in to comment.