laminas / laminas-form

Validate and display simple and complex forms, casting forms to business objects and vice versa
https://docs.laminas.dev/laminas-form/
BSD 3-Clause "New" or "Revised" License
80 stars 52 forks source link

IntlDateFormatter::SHORT is not handled correctly by date-time select helper #236

Closed pine3ree closed 8 months ago

pine3ree commented 1 year ago

The helper assumes that any parsed date-time pattern returns an array with a second key: https://github.com/laminas/laminas-form/blob/d20ba468fad89a23e68ed679b6b827543e166afa/src/View/Helper/FormDateTimeSelect.php#L107

pine3ree commented 1 year ago

There are a couple of solution for this:

  1. Always use the long format for time (Removing setter and arguments BC) and use shouldShowSeconds
  2. Set shouldShowSeconds to false if $pattern['second'] is not set, moving all related parts inside the conditional https://github.com/laminas/laminas-form/blob/d20ba468fad89a23e68ed679b6b827543e166afa/src/View/Helper/FormDateTimeSelect.php#L132

There is also another wrong assumption: https://github.com/laminas/laminas-form/blob/d20ba468fad89a23e68ed679b6b827543e166afa/src/View/Helper/FormDateTimeSelect.php#L137 as in some locales the time part comes before the date part, so assuming the index number for a delimiter makes little sense