cakephp / chronos

A standalone DateTime library originally based off of Carbon
http://book.cakephp.org/chronos
MIT License
1.34k stars 61 forks source link

2.4.x: diffInWeekdays() is 1 for same day #445

Closed mrtnmtth closed 8 months ago

mrtnmtth commented 8 months ago

There is a regression in DifferenceTrait::diffInWeekdays() for Chronos 2.4.x

Code example:

$input = new FrozenDate();
$input = FrozenDate::instance($input);
$today = new FrozenDate();
echo $today->diffInWeekdays($input);

In 2.3.3 the result is 0 as I would expect.

In 2.4.3 diffInWeekdays() returns 1.


Edited the example code because I had it wrong at first.

mrtnmtth commented 8 months ago

Found the cause of the issue. It's this hack in DifferenceTrait::diffFiltered().

https://github.com/cakephp/chronos/blob/96f28ddfceba2ff56e0d2405c28d789bd546ff55/src/Traits/DifferenceTrait.php#L185-L190

mrtnmtth commented 8 months ago

Thanks a lot for fixing.

Will you push a bugfix release for version 2.4?