mirasvit / module-blog

Magento 2 Blog Extension
https://mirasvit.com/magento-2-extensions/blog.html
Open Software License 3.0
68 stars 48 forks source link

IntlDateFormatter pattern - publishing date not editable #93

Closed dio5 closed 6 years ago

dio5 commented 6 years ago

In one environment, the parsing of the date of a post through IntlDateFormatter returns false (i.e. a parse error) because it does not deal well with the pattern that contains a dot after the month:

new \IntlDateFormatter( $this->context->getLocaleResolver()->getLocale(), \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT, null, null, 'MMM. d, y h:mm a' );

in Controller/Adminhtml/Post/Save.php

As a result of this, if you edit an old post, its created (published) date is always overwritten with a default date (current timestamp in the database) and you can not put it back.

The pattern contains a dot after the month, but this is not present in the actual data. Removing the dot fixes the issue.

The dot was causing issues only one environment though, with 2 others being fine.

Now, if you look at Block/Adminhtml/Post/Edit/Sidebar/Publish.php, there date_format is defined as

'date_format' => 'MMM d, y'

without the dot. So is this a bug?

selection_586