The Date Time enhancer (\Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer\DateTimeFromStringEnhancer) only supports one date value.
I know that there is a rework of enhancers on the 8.x-2.x branch. Looking at it, this can be ported there as well with minimal effort.

Comments

vtcore created an issue. See original summary.

vtcore’s picture

StatusFileSize
new1.4 KB

Patch suggestion.

e0ipso’s picture

Status: Active » Needs review
e0ipso’s picture

Thanks for the patch. Kicking off tests.

vtcore’s picture

Tests seem to pass. Can you commit to the 1.x branch?

  • e0ipso committed 5d80d63 on 8.x-1.x authored by vtcore
    Issue #2953227 by vtcore: Date Time enhancer does not work with Date...
e0ipso’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
Status: Needs review » Active

Fixed for 1.x (unsupported), now opening for 2.x.

  • e0ipso committed c7a91cc on 8.x-1.x
    Revert "Issue #2953227 by vtcore: Date Time enhancer does not work with...
e0ipso’s picture

:-( I had to revert this commit because this is breaking the JSON Schema for these fields, while trying to port it to 2.x.

Take a look at getJsonSchema in DateTimeEnhancerBase.

ndobromirov’s picture

Status: Active » Needs review
StatusFileSize
new2.41 KB

Hi here is an attempt to have the schema correct with the string / array of strings variation.

ndobromirov’s picture

StatusFileSize
new2.52 KB

Here is another iteration of the patch that now I was able to test and schema validation passes on date range fields.

  • ndobromirov authored 5837e8d on 8.x-3.x
    Issue #2953227 by ndobromirov, vtcore, e0ipso: Date Time enhancer does...
e0ipso’s picture

Status: Needs review » Fixed

Thanks for this contribution! Sorry it took so long to get it merged.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

andsigno82’s picture

Hi, have to reopen this. using the 3.x-dev version.
the enhancer still return this error when you select either datetime or timestamp

AH01071: Got error 'PHP message: TypeError: DateTime::__construct() expects parameter 1 to be string, array given in /contenta/web/core/lib/Drupal/Component/Datetime/DateTimePlus.php