GithubHelp home page GithubHelp logo

Support for holidays about opening-hours HOT 5 CLOSED

ziming avatar ziming commented on June 2, 2024
Support for holidays

from opening-hours.

Comments (5)

kylekatarnls avatar kylekatarnls commented on June 2, 2024

Hello,

it result in error

Please print the error, the actual output and the output you expect. The example you copy-paste from the doc works in the sandbox https://play.phpsandbox.io/embed/nesbot/carbon, also in unit tests https://github.com/spatie/opening-hours/actions and in the various contexts I tested it, if you a different output, please show this output and give details about your other dependencies, versions and the rest of the code that might be involved.

Another question would be how is this different from the Schedule class in https://github.com/kylekatarnls/business-time ?

What "this" refers to in this sentence? Schedule is part of the business-time package, it's a way to use it as a service (isolated) without enabling global macros on the Carbon class.

from opening-hours.

ziming avatar ziming commented on June 2, 2024

Hi,

The code example earlier I give is for my 2nd question, not for my 1st question. For my 1st question. The code example that results in an error is:

use Spatie\OpeningHours\OpeningHours;

$openingHours = OpeningHours::create([
    'monday'     => ['09:00-12:00', '13:00-18:00'],
    'tuesday'    => ['09:00-12:00', '13:00-18:00'],
    'wednesday'  => ['09:00-12:00'],
    'thursday'   => ['09:00-12:00', '13:00-18:00'],
    'friday'     => ['09:00-12:00', '13:00-20:00'],
    'saturday'   => ['09:00-12:00', '13:00-16:00'],
    'sunday'     => [],
    'holidaysAreClosed' => true,
  // Note that exceptions will still have the precedence over
  // the holidaysAreClosed option.
  'holidays' => [
    'region' => 'us-ny', // Load the official list of holidays from USA - New York
    'with' => [
      'labor-day' => null, // Remove the Labor Day (so the business is open)
      'company-special-holiday' => '04-07', // Add some custom holiday of your company 
    ],
]]);

The error is Spatie\OpeningHours\Exceptions\InvalidDayName with message 'Day holidaysareclosedisn't a valid day name. Valid day names are lowercase english words, e.g.monday, thursday.'

If I remove holidaysareclosed I get Spatie\OpeningHours\Exceptions\InvalidDayName with message 'Day holidaysisn't a valid day name. Valid day names are lowercase english words, e.g.monday, thursday.'

For my 2nd question, I'm asking about what is the difference between the OpeningHours class in spatie/opening-hours and the Schedule class in your kylekatarnls/business-time as they both seem very similar (https://github.com/kylekatarnls/business-time#multiple-business-hours)

I also now have a new question (3rd question), which is where in kylekatarnls/business-time can I make PRs to to modify public holidays for a particular country? or does kylekatarnls/business-time fetch the countries holidays from some other online source? I tried to look at https://github.com/kylekatarnls/business-time/blob/master/src/BusinessTime/Traits/Holidays.php but I cannot find it there

Lastly, it looks like ur a jedi outcast fan, that is a great game

Thank you

from opening-hours.

kylekatarnls avatar kylekatarnls commented on June 2, 2024

Ah OK, I see, so indeed, holidays can't be used in spatie/opening-hours.

business-time uses business-day to handle holidays + spatie/opening-hours to handle the hours in the week. This allow those who need just one feature to install a smaller package.

I don't think we should implement here the holidays, mostly if we do the same as in Schedule, as it would make it redundant.

What would prevent you to use business-time?

from opening-hours.

ziming avatar ziming commented on June 2, 2024

Ah so I use uninstall spatie/opening-hours and just use your business-time Schedule package instead as Schedule is more feature packed than OpeningHours?

Okay then I shall use the Schedule class instead, hopefully it has all the methods that OpeningHours has.

As for my last question, which files in your business-times package should i edit and make PR if i want to modify a country official holidays? I can't seem to find the right file in your repo to do so.

from opening-hours.

kylekatarnls avatar kylekatarnls commented on June 2, 2024

Schedule has all the features and in any case, you can $us->getOpeningHours() and you'll get the OpeningHours instance used.

Holidays lists are here:
https://github.com/kylekatarnls/business-day/tree/master/src/Cmixin/Holidays

from opening-hours.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.