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

Date from array #78

Closed
cojoj opened this issue Jul 23, 2015 · 4 comments
Closed

Date from array #78

cojoj opened this issue Jul 23, 2015 · 4 comments

Comments

@cojoj
Copy link
Contributor

cojoj commented Jul 23, 2015

@czechboy0 I can't find this anywhere in code so I'll simply ask.
In some responses we're getting date but in form of array of components. Didiyou write a method or extension for handling this?
I only found dateForKey() and optionalDateForKey() but they work with Strings.

We need something to get this array by calling arrayForKey() and return NSDateComponents or date formatted String.

Got any hints how you want it to be implemented? Here are my ideas:

  • add new method to JSON which will return NSDate
  • add extension to NSArray which will create NSDate or NSDateComponents or String

In any case we'll have to manually take fields fromArray and put them in NSDateComponents like:

let components = NSDateComponents()

components.year = array[0]
components.month = array[1]
components.day = array[2]
components.hour = array[3]
components.minute = array[4]
components.second = array[5]

Which kind of sucks...
What's more, Array of components we get from XCS has 7 fields and I wonder what is the 7th one... It doesn't look like a timezone... Nanoseconds?

@cojoj
Copy link
Contributor Author

cojoj commented Jul 23, 2015

The old one [XCS] returns Array of 6 Ints but the new one has 7...

@cojoj
Copy link
Contributor Author

cojoj commented Jul 23, 2015

Confirmed 👌

7th field is a time is same as in String version, so it's SSSZZZZ.

In that case we can convert [Int] to String and pass it to the regular method from JSON.swift. That way we'll save some memory as calendar calculations are expensive.

@czechboy0
Copy link
Member

If that works (would probably warrant a test case for both Xcode 6 and 7)
then 👍

Good job reverse engineering it ;) That's how we do things here!
On Thu, Jul 23, 2015 at 8:18 AM Mateusz Zając notifications@github.com
wrote:

Confirmed 👌

7th field is a time is same as in String version, so it's SSSZZZZ.

In that case we can convert [Int] to String and pass it to the regular
method from JSON.swift. That way we'll save some memory as calendar
calculations are expensive.


Reply to this email directly or view it on GitHub
#78 (comment)
.

@czechboy0
Copy link
Member

Fixed in buildasaurs/BuildaUtils#1

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

No branches or pull requests

2 participants