Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsBetween error function #181

Open
GrupoWebex opened this issue Aug 12, 2019 · 2 comments
Open

IsBetween error function #181

GrupoWebex opened this issue Aug 12, 2019 · 2 comments

Comments

@GrupoWebex
Copy link

public function isBetween($minDateTime, $maxDateTime, $closed = true, $period = 'seconds')
{
        $isAfter = $this->isAfter($minDateTime, $period);
        $isBefore = $this->isBefore($maxDateTime, $period);
@GrupoWebex
Copy link
Author

GrupoWebex commented Aug 14, 2019

public function isBetween($minDateTime, $maxDateTime, $closed = true, $period = 'seconds')
{
        $isBefore = $this->isBefore($maxDateTime, $period);
        $isAfter = $this->isAfter($minDateTime, $period);

        // include endpoints
        if ($closed === true)
        {
            $isSameMin = $this->isSame($minDateTime, $period);
            $isSameMax = $this->isSame($maxDateTime, $period);

            return $isSameMin === true || $isSameMax === true 
                    || ($isBefore === true && $isAfter === true);
        }
        return $isBefore === true && $isAfter === true;
}

@GrupoWebex
Copy link
Author

Update through composer, i my code stop working cause you dont fix this bug.
Please, update on main branch.

Is before = date is before MAXdate, not MINdate
Is After = date is after MINdate, not MAXdate

If you include endpoints ($closed = true), have to check
if date is same as MINdate
if date is same as MAXdate
then
return $isSameMin === true || $isSameMax === true
|| ($isBefore === true && $isAfter === true);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant