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

fix: unable to correctly determine isAlwaysClosed and isAlwaysOpen #262

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

jordyvanderhaegen
Copy link
Contributor

Hi, this PR fixes an issue where the isAlwaysOpen and isAlwaysClosed methods were returning wrong results in cases where exceptions were defined.

Consider the following example, where isAlwaysClosed would return false:

$openingHours = OpeningHours::create([
    'Monday' => [],
    'Tuesday' => [],
    'Wednesday' => [],
    'Thursday' => [],
    'Friday' => [],
    'Saturday' => [],
    'Sunday' => [],
    'exceptions' => [
        '2023-12-24' => [],
    ],
]);

Or this example, where isAlwaysOpen would return false:

$openingHours = OpeningHours::create([
    'Monday' => ['00:00-24:00'],
    'Tuesday' => ['00:00-24:00'],
    'Wednesday' => ['00:00-24:00'],
    'Thursday' => ['00:00-24:00'],
    'Friday' => ['00:00-24:00'],
    'Saturday' => ['00:00-24:00'],
    'Sunday' => ['00:00-24:00'],
    'exceptions' => [
        '2023-12-24' => ['00:00-24:00'],
    ],
]);
  • Introduced everyExceptions method for checking conditions on exceptions.
  • Updated isAlwaysClosed and isAlwaysOpen methods to respect exceptions.
  • Added tests for various scenarios of opening hours and exceptions.

…th exceptions

- Introduced `everyExceptions` method for checking conditions on exceptions.
- Updated `isAlwaysClosed` and `isAlwaysOpen` methods to respect exceptions.
- Added tests for various scenarios of opening hours and exceptions.
@kylekatarnls kylekatarnls merged commit e7b4a12 into spatie:master Nov 27, 2024
9 checks passed
@kylekatarnls
Copy link
Collaborator

Thank you 🙏

@kylekatarnls
Copy link
Collaborator

Released in 4.1.0

@jordyvanderhaegen jordyvanderhaegen deleted the fix/always-open-closed branch November 27, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants