bcosca / fatfree

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!
2.66k stars 446 forks source link

Custom date format not respecting parameters (PHP8.1) #1273

Open campZero opened 1 year ago

campZero commented 1 year ago

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

ikkez commented 1 year ago

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?

iahim commented 1 year ago

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.