spatie / period

Complex period comparisons
https://spatie.be/open-source
MIT License
1.6k stars 72 forks source link

--fix: PERIOD: Test that periods touch each other based on seconds. #69

Closed kukko closed 3 years ago

kukko commented 4 years ago

Make touchesWith to work properly. Previously if the difference between the end and start of the two periods was one day or fewer, it returned true. Now it checks that the two period touches based on difference in seconds.

I had to change some already existing tests, because the tests also relied on that the difference between the periods was one day or fewer.

kukko commented 4 years ago

The tests for PHP 7.2 and 7.1 fails because those does not support trailling comas in function calls. Can I change those tests? Because I think it is unnecessary to call methods like this, but if we remove the trailling comas, we can make code compatible with PHP 7.1 and PHP 7.2.

kukko commented 4 years ago

OFFTOPIC: Can you add the "hacktoberfest-accepted" label to this pull request? Beacuse I found your project because of Hacktoberfest and I would like to participate in the Hacktoberfest with this pull request. :)

kukko commented 4 years ago

Closes #67

brendt commented 4 years ago

Hi @kukko Does this fix the problem though originally raised in #67 ?

I don't see any tests for this behaviour?

$a = Period::make('2018-01-01 06:30:00', '2018-01-01 07:30:00');
$b = Period::make('2018-01-01 09:00:00', '2018-01-01 10:00:00');
$overlap = $a->touchesWith($b);
(true)
kukko commented 4 years ago

Excuse me, I didn't created those tests, but now I made them.

brendt commented 3 years ago

Going to close this one, as there's already a PR that I'm going to merge to fix this issue: https://github.com/spatie/period/pull/68