spatie/holidays
Calculate public holidays by country (ISO alpha-2) with a simple API. Get an array of Holiday objects including localized name, CarbonImmutable date, and type (e.g., national). Supports multiple countries and is easy to extend by adding new country definitions.
am) or other localizations.CarbonImmutable and JSON serialization remain intact.config/app.php or a custom provider.CarbonImmutable instances for Ethiopian dates.am (Amharic) translations via Laravel’s App::setLocale().composer update spatie/holidays
'locales' => [
'am' => 'am', // Amharic support
],
$ethiopianHolidays = Holidays::for('et')->get(); // Ethiopian country code
$ethiopianHolidays->filter(fn (Holiday $h) => $h->name->contains('Timket'));
Holidays::for('et')->setLocale('am')->get(); // Amharic translations
us, de) remain unchanged.nesbot/carbon (Laravel includes this by default).Cache::remember()).$holidays = Holidays::for('et')->get();
setLocale('am')).Cache::remember("holidays:et:2024", 31536000, fn () => Holidays::for('et', 2024)->get());
Cache::remember("holidays:et:2024", 31536000, fn () => Holidays::for('et', 2024)->get());
| Scenario | Impact | Mitigation |
|---|---|---|
| Unsupported country | Returns empty array | Fallback to default country or error. |
| Invalid date range | Empty result | Validate inputs (e.g., Carbon::parse). |
| Locale translation missing | Falls back to default language | Pre-load translations or handle gracefully. |
| Ethiopian-specific errors | Missing holidays/incorrect dates | Validate against Ethiopian calendar. |
| PHP 8.4+ requirement | Breaks on older stacks | Upgrade PHP or fork the package. |
| Holiday rule changes | Outdated Ethiopian data | Monitor changelogs; update proactively. |
Holidays::for('et')->get()) takes <10 minutes.setLocale('am')) require ~30 minutes.et country code").How can I help you explore Laravel packages today?