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

overflow does not behave as expected #111

Closed
fabianmossberg opened this issue Jun 4, 2019 · 2 comments
Closed

overflow does not behave as expected #111

fabianmossberg opened this issue Jun 4, 2019 · 2 comments
Assignees
Labels

Comments

@fabianmossberg
Copy link

fabianmossberg commented Jun 4, 2019

I create opening hours for MONDAY and TUESDAY that are identical.

$open_with_overflow and $open_without_overflow

I create $the_time that is set to Tuesday the 4th of June 2019.

//Tuesday 4th of June 2019, 11.35 am
$the_time = new DateTime('2019-06-04 11:35:00');

$open_with_overflow = OpeningHours::create([
    'overflow' => true,
    'monday'    => ['11:00-18:00'],
    'tuesday'    => ['13:37-15:37'],
]
);

$open_without_overflow = OpeningHours::create([
    'overflow' => false,
    'monday'    => ['11:00-18:00'],
    'tuesday'    => ['13:37-15:37'],
   
]
);

var_dump(
    $open_with_overflow->isOpenAt($the_time),
    $open_without_overflow->isOpenAt($the_time)
);

These two isOpen calls should both result in the same anser, but the output from the above is:

bool(true)
bool(false)

If i change the closing hours on monday to 11.34 they both return false.

It seems like the overflow automatically assumes that the previous days closing time applies to the current date.

This should only be true if the previous days closing time happens BEFORE the current days closing time.

@kylekatarnls kylekatarnls self-assigned this Jun 4, 2019
@kylekatarnls
Copy link
Collaborator

It's indeed a bug, overflow should do nothing until a range has an end smaller than its start.

kylekatarnls added a commit that referenced this issue Jun 4, 2019
…ross-midnight

Fix #111 overflow with simple ranges and add tests
@kylekatarnls
Copy link
Collaborator

Thanks, patch released 2.2.1.

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

No branches or pull requests

2 participants