{"id":13518352,"url":"https://github.com/spatie/holidays","last_synced_at":"2025-05-15T12:06:43.776Z","repository":{"id":216830426,"uuid":"742345387","full_name":"spatie/holidays","owner":"spatie","description":"Calculate which days you don't have to work!","archived":false,"fork":false,"pushed_at":"2025-05-12T15:35:28.000Z","size":825,"stargazers_count":363,"open_issues_count":6,"forks_count":198,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-12T16:48:25.738Z","etag":null,"topics":["date","holidays","php"],"latest_commit_sha":null,"homepage":"https://spatie.be/open-source","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"spatie"}},"created_at":"2024-01-12T09:14:27.000Z","updated_at":"2025-05-12T15:35:24.000Z","dependencies_parsed_at":"2024-02-21T10:24:38.022Z","dependency_job_id":"ff931b1b-de45-47a8-9550-cf55ce818d02","html_url":"https://github.com/spatie/holidays","commit_stats":null,"previous_names":["spatie/holidays"],"tags_count":30,"template":false,"template_full_name":"spatie/package-skeleton-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fholidays","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fholidays/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fholidays/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fholidays/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/holidays/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253785013,"owners_count":21963903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["date","holidays","php"],"created_at":"2024-08-01T05:01:43.875Z","updated_at":"2025-05-15T12:06:38.765Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://github.com/sponsors/spatie"],"categories":["PHP"],"sub_categories":[],"readme":"# Calculate public holidays for a country\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/holidays.svg?style=flat-square)](https://packagist.org/packages/spatie/holidays)\n[![Tests](https://img.shields.io/github/actions/workflow/status/spatie/holidays/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/spatie/holidays/actions/workflows/run-tests.yml)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/holidays.svg?style=flat-square)](https://packagist.org/packages/spatie/holidays)\n\nThis package can calculate public holidays for a country.\n\n```php\nuse Spatie\\Holidays\\Holidays;\n\n// returns an array of Belgian holidays\n// for the current year\n$holidays = Holidays::for('be')-\u003eget();\n```\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/holidays.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/holidays)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require spatie/holidays\n```\n\n## Supported countries\n\nWe support the countries listed in [this directory](https://github.com/spatie/holidays/tree/main/src/Countries). If you want to add a country, please create a pull request.\n\n## Usage\n\nYou can get all holidays for a country by using the `get` method.\n\n```php\nuse Spatie\\Holidays\\Holidays;\nuse Spatie\\Holidays\\Countries\\Belgium;\n\n// returns an array of Belgian holidays\n// for the current year\n$holidays = Holidays::for(Belgium::make())-\u003eget(); \n```\n\nAlternatively, you could also pass an [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) code to the `for` method.\nIn case of region based holidays, these will not be included. Use a country class instead.\n\n```php\nuse Spatie\\Holidays\\Holidays;\n\n// returns an array of Belgian holidays\n// for the current year\n$holidays = Holidays::for('be')-\u003eget();\n```\n\n### Getting holidays for a specific year\n\nYou can also pass a specific year.\n\n```php\nuse Spatie\\Holidays\\Holidays;\n\n$holidays = Holidays::for(country: 'be', year: 2024)-\u003eget();\n```\n\n### Getting holidays between two dates\n\nYou can also get all holidays between two dates (inclusive).\n\n```php\nuse Spatie\\Holidays\\Holidays;\n\n$holidays = Holidays::for('be')-\u003egetInRange('2023-06-01', '2024-05-31');\n```\n\n### Getting holidays in a specific language\n\n```php\n$holidays = Holidays::for(country: 'be', locale: 'fr')-\u003eget();\n```\n\nIf the locale is not supported for a country, an exception will be thrown.\n\n### Determining if a date is a holiday \n\nIf you need to see if a date is a holiday, you can use the `isHoliday` method.\n\n```php\nuse Spatie\\Holidays\\Holidays;\n\nHolidays::for('be')-\u003eisHoliday('2024-01-01'); // true\n```\n\n### Getting the name of a holiday\n\nIf you need the name of the holiday, you can use the `getName` method.\n\n```php\nuse Spatie\\Holidays\\Holidays;\n\nHolidays::for('be')-\u003egetName('2024-01-01'); // Nieuwjaar\n```\n\n### Determining whether a country is supported\n\nTo verify whether a country is supported, you can use the `has` method.\n\n```php\nuse Spatie\\Holidays\\Holidays;\n\nHolidays::has('be'); // true\nHolidays::has('unknown'); // false\n```\n\n## Contributing\n\nThis is a community driven package. If you find any errors, please create a pull request with the fix, or at least open an issue.\n\n## Adding a new country\n\n1. Create a new class in the `Countries` directory. It should extend the `Country` class.\n2. Add a test for the new country in the `tests` directory.\n3. Run the tests so a snapshot gets created.\n4. Verify the result in the newly created snapshot is correct.\n5. If the country has multiple languages, add a file in the `lang/` directory.\n\nIn case your country has specific rules for calculating holidays,\nfor example region specific holidays, you can pass this to the constructor of your country class.\n\n```php\n$holidays = Holidays::for(Germany::make('DE-BW'))-\u003eget();\n```\n\nThe value, `DE-BW`, will be passed to the region parameter of the constructor of a country.\n\n```php\nclass Germany extends Country\n{\n    protected function __construct(\n        protected ?string $region = null,\n    ) {\n    }\n\n    protected function allHolidays(int $year): array\n    {\n        // Here you can use $this-\u003eregion (or other variables) to calculate holidays\n    }\n```\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for more details.\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Niels Vanpachtenbeke](https://github.com/Nielsvanpach)\n- [Freek Van der Herten](https://github.com/freekmurze)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fholidays","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Fholidays","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fholidays/lists"}