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

previousOpen returns next open date #243

Closed
IlliaVeremiev opened this issue Jun 6, 2024 · 1 comment · Fixed by #251
Closed

previousOpen returns next open date #243

IlliaVeremiev opened this issue Jun 6, 2024 · 1 comment · Fixed by #251
Labels

Comments

@IlliaVeremiev
Copy link

IlliaVeremiev commented Jun 6, 2024

Hi! We are using your library (2.41.0) and looking for a way to find last opening time. As I understand previousOpen should do this, but seems that response is not correct. I tried to setup next opening hours:

  • Monday: 18:00 - 05:00
  • Tuesday: 18:00 - 05:00
    And previousOpen with (Tuesday 06:00) returns (Tuesday 18:00), but I expect (Monday 18:00). So it returns nextOpen.

Created a test file such as:

$openingHours = OpeningHours::create([
    'overflow' => true,
    'monday' => ['18:00-05:00'],
    'tuesday' => ['18:00-05:00'],
]);
$tuesday = new DateTime('2024-06-11 06:00:00');
echo 'Today          : ' . $tuesday->format('Y-m-d H:i') . "\n";
echo 'Previous open  : ' . $openingHours->previousOpen($tuesday)->format('Y-m-d H:i') . "\n";
echo 'Previous close : ' . $openingHours->previousClose($tuesday)->format('Y-m-d H:i') . "\n";

Response

Today          : 2024-06-11 06:00
Previous open  : 2024-06-11 18:00
Previous close : 2024-06-11 05:00

Could you please say if there's a problem with configuration or there any solution to solve this issue?

@IlliaVeremiev IlliaVeremiev changed the title previousOpen returns next open next open date previousOpen returns next open date Jun 6, 2024
@kylekatarnls
Copy link
Collaborator

Hello,

I edited the message to use a reproductible code chunk with no dependencies.

Previous close : 2024-06-11 05:00 is correct.

But Previous open should be 2024-06-10 18:00

There is probably something wrong with the overflow.

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

Successfully merging a pull request may close this issue.

2 participants