{"id":20770572,"url":"https://github.com/codemonauts/craft-holidays","last_synced_at":"2025-04-30T13:49:51.250Z","repository":{"id":56955452,"uuid":"229385803","full_name":"codemonauts/craft-holidays","owner":"codemonauts","description":"Craft CMS plugin to work with international holidays","archived":false,"fork":false,"pushed_at":"2022-05-09T16:11:23.000Z","size":25,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-17T03:45:16.947Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/codemonauts.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-21T06:14:28.000Z","updated_at":"2023-12-11T02:25:47.000Z","dependencies_parsed_at":"2022-08-21T08:50:34.281Z","dependency_job_id":null,"html_url":"https://github.com/codemonauts/craft-holidays","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonauts%2Fcraft-holidays","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonauts%2Fcraft-holidays/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonauts%2Fcraft-holidays/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemonauts%2Fcraft-holidays/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemonauts","download_url":"https://codeload.github.com/codemonauts/craft-holidays/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251714676,"owners_count":21631770,"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":[],"created_at":"2024-11-17T12:10:30.266Z","updated_at":"2025-04-30T13:49:51.223Z","avatar_url":"https://github.com/codemonauts.png","language":"PHP","readme":"# International holidays plugin for Craft CMS\n\n![Icon](resources/holidays.png)\n\nA plugin for Craft CMS that provides access to many international holidays.\n\nThis plugin is based on the awesome work of [yasumi](https://azuyalabs.github.io/yasumi/). Go and buy him a coffee!\n\n## Background\n\nThis plugin provides easy access to holidays in many countries. For example to automatically determine if a shop or restaurant is open or closed on an official holiday in a country.\n\n## Coverage\n\nCurrently 35 countries and 85 sub-regions:\n\nAustralia,\nAustria,\nBelgium,\nBosnia \u0026 Herzegovina,\nBrazil,\nCroatia,\nCzechia,\nDenmark,\nEstonia,\nFinland,\nFrance,\nGermany,\nGreece,\nHungary,\nIreland,\nItaly,\nJapan,\nLatvia,\nLithuania,\nNetherlands,\nNew Zealand,\nNorway,\nPoland,\nPortugal,\nRomania,\nRussia,\nSlovakia,\nSouth Africa,\nSouth Korea,\nSpain,\nSweden,\nSwitzerland,\nUnited States,\nUkraine and \nUnited Kingdom\n\nFor more details see [yasumi's feature page](https://azuyalabs.github.io/yasumi/features/). And if you are missing your country, why not contribute by adding a new provider for your country?\n\n## Requirements\n\n * Craft CMS \u003e= 4.0.0\n\n## Installation\n\nOpen your terminal and go to your Craft project:\n\n``` shell\ncd /path/to/project\ncomposer require codemonauts/craft-holidays\n./craft install/plugin holidays\n```\n\nSwitch to the settings page in the control panel and enter select your default country and subregion.  \n\n## Usage\n\nYou can query for holidays like for entries:\n\n``` twig\n\u003cul\u003e\n{% for holiday in craft.holidays.type('official').between('last monday', '2019-12-31').all() %}\n\u003cli\u003e{{ holiday.format('Y-m-d') }}: {{ holiday.getName() }}\u003c/li\u003e\n{% endfor %}\n\u003c/ul\u003e\n```\n\nor same in php:\n\n``` php\nuse codemonauts\\holidays\\base\\Holidays;\n\n$holidays = Holidays::find()\n    -\u003etype('official')\n    -\u003ebetween('last monday', '2019-12-31')\n    -\u003eall();\n ```\n\n### Filtering\n\nYou can combine the following filters in any order:\n\n`type(typename)` specifies the type of holidays to return. Default is `Null`. Possible other types are:\n* 'official'\n* 'observance'\n* 'season'\n* 'bank'\n* 'other'\n* Null (means \"all\")\n\n`country(code)` sets the country for which the holidays should be returned. The code is the [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) code of the country and its subregion. You can set the default country in the settings.\n\n`locale(code)` sets the locale code to translate the holidays names to. The default is set to your site locale in Craft CMS.\n\n`year(year)` specifies for which year the holidays are returned. You can only get the holidays for one specific year. This is set automatically to the date set by `on()` or `between()`. Normally you do not need to specify anything here.    \n\n`on(date)` sets a single date to check for holidays. You can provide a DateTimeInterface or a date string like '2019-12-25' or a string that can be parsed by [strtotime](https://www.php.net/manual/en/datetime.formats.php).\n\n`between(startDate, endDate)` filter for a time range. Same rules as for `on(date)`.\n\n### Fetching\n\nTo fetch the results you have different functions:\n\n`one()` returns the first holiday as an extended DateTime object (see results).\n\n`all()` returns all holidays as array (actually an iterator) of extended DateTime objects.\n\n`count()` returns the number of holidays found.\n\n`isHoliday()` returns true or false if a holiday exists.\n\n### Results\n\nAs result you get a DateTime object with the following extensions:\n\n`getType()` returns the type of holiday.\n\n`getName()` returns the translated name of the holiday. If for the given locale no translation is defined, the name in 'en_US' is returned.\n\n## Examples\n\nGet all holidays of a year:\n\n``` twig\ncraft.holidays.year(2019).all()\n ```\n\nGet all official holidays of a time range:\n\n``` twig\ncraft.holidays.type('official').between(entry.postDate, '2019-12-31').all()\n ```\n\nCheck if today is a official holiday in Japan:\n\n``` twig\ncraft.holidays.type('official').on('now').country('JP').isHoliday()\n ```\n\n## Settings\n\nYou can set the default country and subregion in a config file placed in your CraftCMS config directory. You can find the most recent version in src/config.php. You have to name the file ``holidays.php``.\n\n``` php\nreturn [\n    // Default country code in ISO 3166-2 (https://en.wikipedia.org/wiki/ISO_3166-2) notation.\n    // E.g. DE-HE, US-CA \n    'defaultCode' =\u003e '',\n];\n```\n\nIf you do not set a default country code or the country code could not be found, we fall back to `US`.\n\nWith ❤ by [codemonauts](https://codemonauts.com)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonauts%2Fcraft-holidays","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemonauts%2Fcraft-holidays","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemonauts%2Fcraft-holidays/lists"}