cakephp / chronos

A standalone DateTime library originally based off of Carbon

Home Page:http://book.cakephp.org/chronos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

mrtnmtth opened this issue · comments

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.

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

// Hack around DatePeriod not including end values.
// When handling dates we need to convert to a DateTime
// and offset by 1 second.
if ($end instanceof ChronosDate) {
$end = (new Chronos($end))->modify('+1 second');
}

Thanks a lot for fixing.

Will you push a bugfix release for version 2.4?