Switch the default date formatter to ISO-8601. closes #1069, refs #1010

This commit is contained in:
Blake Watters
2012-12-11 21:51:53 -05:00
parent ae6b58d7bc
commit 138bbddfcd
3 changed files with 14 additions and 13 deletions

View File

@@ -375,7 +375,9 @@
/**
Returns the preferred date formatter to use when generating NSString representations from NSDate attributes. This type of transformation occurs when RestKit is mapping local objects into JSON or form encoded serializations that do not have a native time construct.
Defaults to a date formatter configured for the UTC Time Zone with a format string of "yyyy-MM-dd HH:mm:ss Z"
Defaults to an instance of the `RKISO8601DateFormatter` configured with the UTC time-zone. The format string is equal to "YYYY-MM-DDThh:mm:ssTZD"
For details about the ISO-8601 format, see http://www.w3.org/TR/NOTE-datetime
@return The preferred NSFormatter object to use when serializing dates into strings
*/

View File

@@ -383,7 +383,7 @@ static RKSourceToDesinationKeyTransformationBlock defaultSourceToDestinationKeyT
/////////////////////////////////////////////////////////////////////////////
static NSMutableArray *defaultDateFormatters = nil;
static NSDateFormatter *preferredDateFormatter = nil;
static NSFormatter *preferredDateFormatter = nil;
@implementation RKObjectMapping (DateAndTimeFormatting)
@@ -440,11 +440,10 @@ static NSDateFormatter *preferredDateFormatter = nil;
+ (NSFormatter *)preferredDateFormatter
{
if (!preferredDateFormatter) {
// A date formatter that matches the output of [NSDate description]
preferredDateFormatter = [NSDateFormatter new];
[preferredDateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss Z"];
preferredDateFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
preferredDateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
RKISO8601DateFormatter *iso8601Formatter = [[RKISO8601DateFormatter alloc] init];
iso8601Formatter.defaultTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
iso8601Formatter.includeTime = YES;
preferredDateFormatter = iso8601Formatter;
}
return preferredDateFormatter;