laravel-carbon-holidays

Versie
4.0.0
Downloads
13.364 downloads
Sterren
3
Licentie
MIT
GitHub

Configuration

Publishing the Config

You can publish the configuration file to customize which holidays are recognized:

php artisan vendor:publish --tag="laravel-carbon-holidays"

This creates config/holidays.php in your application.

Configuration Options

Each holiday can be enabled (true) or disabled (false):

return [
    'new_year' => true,
    'good_friday' => true,
    'easter_sunday' => true,
    'easter_monday' => true,
    'kings_day' => true,
    'liberation_day' => true,
    'ascension_day' => true,
    'pentecost' => true,
    'pentecost_monday' => true,
    'christmas_day' => true,
    'boxing_day' => true,
];

Liberation Day Special Options

Liberation Day supports three configuration modes:

// Always a holiday (default)
'liberation_day' => true,

// Never a holiday
'liberation_day' => false,

// Only a holiday once every 5 years (2020, 2025, 2030, etc.)
'liberation_day' => 'once-every-5-years',

Historically, Liberation Day in the Netherlands was only a public holiday once every 5 years. The 'once-every-5-years' option implements this by checking if the year is divisible by 5.

Important Notes

  • Configuration only affects isHoliday() - The general isHoliday() method respects your configuration
  • Individual methods always work - Methods like isNewYear(), isChristmasDay(), etc. check the actual date regardless of configuration
  • Example:
// With 'good_friday' => false in config
$date = Carbon::parse('2021-04-02');

$date->isHoliday();     // false (respects config - Good Friday disabled)
$date->isGoodFriday();  // true (checks the actual date - it IS Good Friday)

This allows you to:

  • Control which holidays isHoliday() recognizes for your application
  • Still use individual methods to check if a date matches a specific holiday

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Een fout gevonden of een vraag? Maak een issue aan op GitHub.