-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
holiday or festive days? #116
Comments
That would be incredibly complicated, do you know how many days are considered holidays all countries combined ? |
I think, but if we would use, we can add a config array of days for example: |
And somes holydays (like Easter) are not same dates each year. MyCarbon extends Carbon {
public function isHoliday() {
return in_array([ $this->month, $this->day ], [
[12, 25], // Christmas
[01, 01], // New Year
...
]);
}
} |
I think what Carbon needs is a macro functionality so you can add your own feature over it. If you need to define the holidays yourself this is pretty much what this would be. Carbon::macro('isHoliday', function ($date) {
return in_array($date->format('Y-m-d'), [holidays]);
});
Carbon::parse('some-date')->isHoliday(); Something like that, that would allow people to add helpers for their edge cases, what do you think @briannesbitt ? |
great! thanks! |
There is a set of packages that is trying to solve just that. |
Good luck with that, incredibly complicated to do something like that! BTW, christmas in Germany is always the 24th of December, not the 25th. |
I rather this be done in a sub class than adding macro functionality. If it then becomes flushed out and useful for others (and a common issue) then we can look at pulling it in. |
I created a PR which adds Carbon extensions that check to see if a given date is a business day. Custom holiday and business schedules can be provided which allow you to properly determine what the date is for next or previous number of business days. |
Will appear in the documentation: |
it can be possible have some method like isWeekend but isHoliday establishing an array or by location, to know if date is on holiday?
The text was updated successfully, but these errors were encountered: