New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Importing NSDate from Unix Timestamp #627
Conversation
Hi, Until the pull is accepted:
|
+1 |
@tonyarnold will this pull request be merged soon ? if not is there a workaround. thanks |
+1 will this ever be merged ? |
I'm so sorry guys — I intended to check all of this (and a few other date import PRs) over months ago, but I haven't had much time to work on MR lately. I'll check this out later tonight and merge the changes into the |
Quick update: Every single test in the 3.0 branch is broken. I'm fixing them this morning, then this. Bear with me. |
So I've merged this into MagicalRecord 3.0 — does anybody urgently need this in MagicalRecord 2.x? I wasn't planning on an MR 2.x release for a little while (at least until after MR 3 is finished). |
@tonyarnold it would be life saving for me as it will allow me to do a work around for #700 . thanks |
I have added support for importing from JSON where dates are represented as Unix timestamps.
If a value that maps to an NSDate attribute in Core Data appears in the JSON as a string, the importing behavior is unchanged from before.
If the value appears in the JSON as a number and nothing is specified in the date attribute's userInfo for the key
dateFormat
, I assume the number represents the number of seconds since 1970 (10 digits). For JSON that represents its dates as the number of milliseconds since 1970 (13 digits), add the valueunixTime13
for keydateFormat
in the userInfo.I have provided tests.