flack / ranger

Formatter for date and time ranges with i18n support
73 stars 15 forks source link

Time weirdly merged when both dates are identically #8

Closed gglnx closed 2 years ago

gglnx commented 2 years ago

If I provide the same date with the same time, the time output is weirdly merged.

$ranger = new OpenPsa\Ranger\Ranger('de');
$ranger->setTimeType(IntlDateFormatter::SHORT);
$ranger->format('2022-05-04 20:00:00', '2022-05-04 20:00:00');

The output is 04.05.2022, 20:00 – 00.

I would except the output to be 04.05.2022, 20:00.

flack commented 2 years ago

hm, that is weird. Which PHP version are you using exactly? I just tried your sample code on my system with PHP 7.4.29, and I get 04.05.2022, 20:00 as output, as expected. Is the intl extension installed on your system?

gglnx commented 2 years ago

I'm using PHP 8.1.4 with intl enabled

flack commented 2 years ago

ah, interesting. it really seems to only happen on PHP 8.0 and 8.1. Will take a look

flack commented 2 years ago

Alright, I've debugged this. Turned out we did some wrong max() calls on strings, which somehow worked fine in PHP 7..

but well, test & fix are committed now