handle Date objects in adition to DateTimes

This commit is contained in:
jeremy@twotoasters.com
2010-01-15 13:04:28 -05:00
parent 9686d78449
commit 10fcdeb338
2 changed files with 7 additions and 2 deletions

View File

@@ -10,7 +10,8 @@
#import "ElementParser.h"
#import "OTRestModelMappableProtocol.h"
#define kRailsToXMLDateFormatterString @"yyyy-MM-dd'T'HH:mm:ss'Z'" // 2009-08-08T17:23:59Z
#define kRailsToXMLDateTimeFormatterString @"yyyy-MM-dd'T'HH:mm:ss'Z'" // 2009-08-08T17:23:59Z
#define kRailsToXMLDateFormatterString @"MM/dd/yyyy"
typedef enum {
OTRestMappingFormatXML = 0,

View File

@@ -279,8 +279,12 @@
// Times coming back are in utc. we should convert them to the local timezone
// TODO: Need a way to handle date/time formats. Maybe part of the mapper?
[formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
[formatter setDateFormat:kRailsToXMLDateFormatterString];
[formatter setDateFormat:kRailsToXMLDateTimeFormatterString];
propertyValue = [formatter dateFromString:dateString];
if (nil == propertyValue) {
[formatter setDateFormat:kRailsToXMLDateFormatterString];
propertyValue = [formatter dateFromString:dateString];
}
[formatter release];
}
} else if ([type isEqualToString:@"nil"]) {