PHP code example of hashandsalt / kirby3-yasumi

1. Go to this page and download the library: Download hashandsalt/kirby3-yasumi library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hashandsalt / kirby3-yasumi example snippets


$site->holidays('USA', 2020);

$site->holidays('Netherlands', date("Y"));

$holidays = $site->holidays('France', 2020);

$days = [];
foreach ($holidays->getHolidayDates() as $date) {
  $days[] = $date;
}

dump($days);



// Get set of dates from Recurr
$events = $site->recurr('2020-01-01 20:00:00', '2020-01-01 22:00:00', 'WEEKLY', ['WE', 'TH', 'FR'], '2021-01-26');

// Get Holidays for USA for Current Year
$holidays = $site->holidays('USA', date("Y"));

// Turn those holidays in to an array of just dates
$filter = [];
foreach ($holidays->getHolidayDates() as $date) {
  $filter[] = $date;
}

// Filter out those dates from events
$filteredEvents = array_filter($events, function($event) use ($filter) {
  $event = implode('//', $event);

  foreach($filter as $day) {
    // if contains then discard
    if (strstr($event, $day) !== false) {
      return false;
    }
  }
  // else keep
  return true;
});

dump($filteredEvents);




return [
    'hashandsalt.yasumi' => [
        'country' => 'Germany/LowerSaxony',
        'year' => '2020',
        'locale' => 'de_DE'
    ]
]