Improve date handling

Created on 13 September 2018, almost 6 years ago
Updated 18 June 2024, 11 days ago

The way we are dealing with dates & their different formats currently needs be looked at and improved upon.

Following comments were made by Wim Leers at #2995140: External Entities 2.x β†’ :

  1. RE: // TODO: What about dates and their original format? I would strongly recommend to look at the date format choices that were made in CR JSON API now (de)normalizes Timestamp fields to/from ISO timestamps, not UNIX timestamps β†’ , which were based on those in #2926508: Add DateTimeNormalizer+TimestampNormalizer, deprecate TimestampItemNormalizer: @DataType-level normalizers are reusable by JSON:API β†’ . Basically: the formats that are used most widely in internet standards!
  2. Adding to the previous point: you can continue to send the "as stored by Drupal" data. But your TODO points to the underlying problem doing that: integers are integers, strings are strings, but booleans can be represented in multiple ways, and there are even more possible representations with date/time! What you actually want, is the ability to configure transformations. The only module that does this to some extent as far as I know is https://www.drupal.org/project/jsonapi_extras β†’ . If you want to consider doing this too, then \Drupal\jsonapi_extras\Plugin\DateTimeEnhancerBase is the best starting point for inspiration.
  3. Also adding to this: instead of points 1/2, wouldn't it be simpler to require the storage client to perform the necessary transformations? Then you could demand that timestamps are always represented in RFC3339 format.
✨ Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium rp7

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡«πŸ‡·France guignonv

    I'm digging up an old thread but maybe it could be marked as "closed (work as designed)".
    Whatever date format that come from the storage client will need to be turned into something Drupal manages, that's a point. But I don't think we really should do something special to manage what format comes from the storage client from the storage client perspective itself. I believe the current philosophy of External Entities is to have a storage client that manages to extract raw data from a source and then, use a field mapper to adapt that raw data into something Drupal can handle. Therefore, managing date and time format should be the job of a field mapper. And that's it for that issue.

    However, this discussion brings be to another one that should fit into a different topic: being able to combine field mappers depending on the nature of the fields we need to map (ie. having a dedicated date field mapper that could be used in combination with other field mappers).

Production build 0.69.0 2024