twill
twill copied to clipboard
Different datetime format parsings => format conflicts when using configuration "publish_date_display_format"
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.
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
Steps to reproduce
- you must have created a module (i.e.
Article
) - 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,
];
- make sure the module has db columns
publish_start_date
andpublish_end_date
- make sure the twill config has been set with
'publish_date_display_format' => 'DD.MM.YYYY HH:mm'
- open the twill administration panel and open the list for your module
- make sure one element has been created and it has a scheduled publish date (start or end)
- check the format in the list view
- 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