Restkit Parse ActiveRecord Timestamp
If you are using Rails as your backend, Reskit will have trouble to parse ActiveRecord timestamp.
Default ActiveRecord timestamp JSON out is 2008-12-29T00:27:42-08:00
You can not convert it to NSDate directly use NSDateFomatter
you must convert it to 2008-12-29T00:27:42-0800
But you have not chance to convert when you use Restkit Mapping.
Here is my solution
1. Monkey patch Time and DateTime class
def as_json(option=nil)
self.strftime("%Y-%m-%dT%H:%m:%S%z")
end
end
def as_json(format=nil)
self.strftime("%Y-%m-%dT%H:%m:%S%z")
end
end
2. Add default date fomatter to RKObjectMapping
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"];
[RKObjectMapping addDefaultDateFormatter:dateFormatter];

