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

nextOpen() returns wrong result if input array does not have slots in ascending order #128

Closed
jaysson opened this issue Jul 6, 2019 · 1 comment
Assignees

Comments

@jaysson
Copy link

jaysson commented Jul 6, 2019

$schedule = Carbon::now()->setDateTime(2019, 7, 6, 11, 29);

// Returns 2019-07-06 19:00:00
OpeningHours::createAndMergeOverlappingRanges(['saturday' => ['19:00-22:30','12:00-15:30']])->nextOpen($schedule);

// Returns 2019-07-06 12:00:00
OpeningHours::createAndMergeOverlappingRanges(['saturday' => ['12:00-15:30', '19:00-22:30']])->nextOpen($schedule);

May be the slots can be ordered while creating the OpeningHours?

@kylekatarnls
Copy link
Collaborator

I approve the idea.

Next version will allow unordered ranges:
#129

For the record, https://github.com/kylekatarnls/business-time allow you to enable opening hours globally on Carbon, so you can do: Carbon::parse('2019-07-06 11:29')->nextOpen() if you don't need multiple OpeningHours instances.

kylekatarnls added a commit that referenced this issue Jul 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants