Comments (5)
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.
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.
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.
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.
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)
- several advanced features HOT 4
- Github URL update HOT 2
- [Question/Feature Request] How to get all days of the current week including days resulting from exceptions? HOT 3
- [Bug] nextOpen calculates the wrong date for a regular day with exceptions HOT 3
- timezone is set on passed object when getting hours for a specific date HOT 2
- Free time slots during the day ? HOT 1
- nextOpen not respecting timezone HOT 2
- Timezone not working in currentOpenRange HOT 2
- I want to add schedule for specific date HOT 1
- Locale? HOT 1
- GitHub repository link not working HOT 2
- Overflow support does not seem to work for createAndMergeOverlappingRanges HOT 2
- diffInOpenMinutes() does not work if only one day is configured as open HOT 6
- Date period in exceptions or start and end date for a set of days of the week in regular time HOT 4
- Exceptions with date ranges HOT 5
- [Feature request] createFromStructuredData method
- How to destroy OpeningHours object or update it ? HOT 1
- How to create an exception using datetime with seconds HOT 2
- Adding seconds precision to exceptions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opening-hours.