forked from azuyalabs/yasumi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbetween_filter.php
More file actions
40 lines (32 loc) · 1.11 KB
/
between_filter.php
File metadata and controls
40 lines (32 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
declare(strict_types = 1);
/**
* This file is part of the 'Yasumi' package.
*
* The easy PHP Library for calculating holidays.
*
* Copyright (c) 2015 - 2026 AzuyaLabs
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Sacha Telgenhof <me at sachatelgenhof dot com>
*/
// This file demonstrates the use of the `between` filter, selecting only a number of holidays
// that fall in the given date range.
require 'vendor/autoload.php';
$year = (int) date('Y');
// Use the factory to create a new holiday provider instance
$holidays = Yasumi\Yasumi::create('Italy', $year);
$holidaysInDecember = $holidays->between(
new DateTime("12/01/{$year}"),
new DateTime("12/31/{$year}")
);
// Show all holidays in Italy for December
echo 'List of all the holidays in December: ' . PHP_EOL;
foreach ($holidaysInDecember as $holiday) {
echo $holiday . ' - ' . $holiday->getName() . PHP_EOL;
}
echo PHP_EOL;
// Show the number of filtered holidays
echo "Number of filtered holidays: {$holidaysInDecember->count()}" . PHP_EOL;