twill icon indicating copy to clipboard operation
twill copied to clipboard

Different datetime format parsings => format conflicts when using configuration "publish_date_display_format"

Open emanueljacob opened this issue 1 year ago • 0 comments

Description

The twill config publish_date_display_format allows, setting the display format of dates within twill. Unfortunately the settings format is being used with different parsers so the format conflicts in either the one or the other output rendering. The config is (at least) being used in the following files:

  • frontend/js/utils/filters.js based on JS
  • src/Services/Listings/Columns/ScheduledStatus.php (\A17\Twill\Services\Listings\Columns\ScheduledStatus) based on PHP

So if one sets a PHP datetime format then the ouput in listings publish columns is correct, but in edit screens its incorrect or vice versa.

Example:

If one sets the setting to 'publish_date_display_format' => 'DD.MM.YYYY HH:mm', the output is correct and expected and looks fine within the edit screen. However if one checks the output of the publish columns ( includeScheduledInList indexoption must be set) then the output is incorrect. See the following screenshots.

SCR-20240105-kawm SCR-20240105-kagp

Of course you may edit the setting to somthing that is valid in terms of PHPs dateTime formats, i.e. 'publish_date_display_format' => 'd.m.Y H:m', so the output is correct in the listing views (publish column) but then the rendered output is incorrect in the edit screen. See the following screenshots

SCR-20240105-kbdk SCR-20240105-kbhg

Steps to reproduce

  1. you must have created a module (i.e. Article)
  2. In your Module Controller, i.e. ArticleController, make sure the $indexOptions property is set with a key value pair 'includeScheduledInList' => true example.

protected $indexOptions = [
    'permalink' => false,
    'includeScheduledInList' => true,
];
  1. make sure the module has db columns publish_start_date and publish_end_date
  2. make sure the twill config has been set with 'publish_date_display_format' => 'DD.MM.YYYY HH:mm'
  3. open the twill administration panel and open the list for your module
  4. make sure one element has been created and it has a scheduled publish date (start or end)
  5. check the format in the list view
  6. check the format in the edit view

Expected result

both date format is being parsed always the same, and shows the same format after rendering at all date locations that are using the configuration.

i personally would expect it to follow the formats defined by datetime formats, but it would also be ok to use a different format. But it is always expected to be the same for all date formats within the package

Actual result

the format is parsed differently at different locations (see example above).

Versions

Twill version: 3.0.2 Laravel version: 10.39 PHP version: 8.2 Database engine: mysql

emanueljacob avatar Jan 05 '24 10:01 emanueljacob