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

Changes dates represented as strings to dates represented as a Date type #254

Closed
bidoubiwa opened this issue Feb 8, 2022 · 2 comments · Fixed by #425
Closed

Changes dates represented as strings to dates represented as a Date type #254

bidoubiwa opened this issue Feb 8, 2022 · 2 comments · Fixed by #425
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@bidoubiwa
Copy link
Contributor

bidoubiwa commented Feb 8, 2022

Description
In the task structure multiple fields represents dates but are typed as strings. It would be an improvement to change these dates to a Date type object and not a string,

Example can be found here:

public let processedAt: String?

Currently the decoder is not able to transform the returned date format by Meilisearch into a Date object in swift. See error:

▿ Swift.DecodingError.dataCorrupted
  ▿ dataCorrupted: Swift.DecodingError.Context
    ▿ codingPath: 1 element
      - CodingKeys(stringValue: "duration", intValue: nil)
    - debugDescription: "Date string does not match format expected by formatter."
    - underlyingError: nil

Meilisearch is returned date the following way:

   "enqueuedAt": "2021-08-10T14:29:17.000000Z",

Which per the specs is described like this (for example with enqueuedAt):

| enqueuedAt | string | Represent the date and time as `ISO-8601` format when the task has been enqueued |
@bidoubiwa bidoubiwa added the enhancement New feature or request label Feb 8, 2022
@bidoubiwa bidoubiwa added the good first issue Good for newcomers label Feb 8, 2022
@brunoocasali
Copy link
Member

I had a similar problem when upgrading the dart SDK: https://github.com/meilisearch/meilisearch-dart/blob/main/lib/src/client_impl.dart#L160 so I had to make a workaround in order to be able to serialize it.
Not sure if helps 👯

@bidoubiwa
Copy link
Contributor Author

For the moment there are two API in swift. One called Date that has a ISO8601Format(_:) method but only compatible with MacOS 12+
The other is called DateFormatter and I believe with this API it is easy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants