supermarin / ObjectiveRecord

ActiveRecord-like API for CoreData
MIT License
1.29k stars 194 forks source link

custom NSDate format #64

Open JanC opened 10 years ago

JanC commented 10 years ago

Hi, is there a way of setting a date formatter for parsing dates? In the JSON answer I'm getting, the dates are set as milliseconds since 1970 e.g.

"anniversary": 1388646266064

cheers

supermarin commented 10 years ago

@JanC there was a PR to expose the dateFormatter so people can set their own date format. I think that one'll go into production

CaseyB commented 9 years ago

I can override - (NSDateFormatter *)defaultFormatter in my NSManagedObject subclass but some of the fields have different formats within the same model. Any suggestions on overriding the date format per attribute?

stephencelis commented 9 years ago

@CaseyB Could you make your formats consistent? That would probably be ideal. If you need field-specific formats, you're best off overriding each attribute yourself and using the primitive getter/setters, etc.

CaseyB commented 9 years ago

Unfortunately I don't have control over the format from the server. We were using MagicalRecord and it gave us the option to map a date format per attribute but it had a lot of other shortcomings. So far ObjectiveRecord is great, this is the only real snag I've hit.