bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom date format not respecting parameters (PHP8.1)

campZero opened this issue · comments

commented

I have a calendar that should get its title from the selected month, which used to work in older versions of PHP, unfortunately strftime is deprecated and the replacement in F3 does not really work with custom parameters.

{{ Base::instance()->format('{0,date,custom,%B %Y}', @Date) }}
{{ Base::instance()->format('{0,date,custom,MMMM YYYY}', @Date) }}

with @Date being a timestamp, will return 1. August 2023, although it should return August 2023.

If I read the code correctly, the date portion does not accept custom parameters when in the php8.1 branch.
base.php@line1068

Sadly, there's no replacement for the parameters of strftime. The IntlDateFormatter uses a whole set of different parameters. Also I'm wondering, having a custom format option would actually defeat the purpose of a unified formatter, wouldn't it? So shall we add the custom option back again, which will certainly fail when on 8.1+ without adjustments or just drop that feature and encourage devs to simply register a custom formatter, what do you think?

commented

We should stick to whatever the norm is now. In the end one can always write a small wrapper function to customize a date output.