Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

benrobjoh
Copy link

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 value unixTime13 for key dateFormat in the userInfo.

I have provided tests.

@ghost ghost assigned tonyarnold Dec 30, 2013
@JanC
Copy link

JanC commented Jan 3, 2014

Hi,
that's what I need as well thanks!

Until the pull is accepted:

pod 'MagicalRecord',  :git => 'https://github.com/benrobjoh/MagicalRecord.git', :branch=>'unix-date'

@losingle
Copy link

losingle commented Jan 5, 2014

+1

@aminebellakrid
Copy link

@tonyarnold will this pull request be merged soon ? if not is there a workaround. thanks

@JanC
Copy link

JanC commented Mar 23, 2014

+1 will this ever be merged ?

@tonyarnold
Copy link
Contributor

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 release/3.0 branch (assuming all the tests pass, etc).

@tonyarnold
Copy link
Contributor

Quick update: Every single test in the 3.0 branch is broken. I'm fixing them this morning, then this. Bear with me.

tonyarnold added a commit that referenced this pull request Mar 25, 2014
@tonyarnold
Copy link
Contributor

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).

@aminebellakrid
Copy link

@tonyarnold it would be life saving for me as it will allow me to do a work around for #700 . thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants