|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the Yasumi package. |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright (c) 2015 - 2020 AzuyaLabs |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
* |
|
10
|
|
|
* @author Sacha Telgenhof <[email protected]> |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Yasumi\Provider; |
|
14
|
|
|
|
|
15
|
|
|
use DateTime; |
|
16
|
|
|
use Yasumi\Exception\InvalidDateException; |
|
17
|
|
|
use Yasumi\Exception\UnknownLocaleException; |
|
18
|
|
|
use Yasumi\Holiday; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Provider for all holidays in Hungary. |
|
22
|
|
|
* |
|
23
|
|
|
* @author Aron Novak <[email protected]> |
|
24
|
|
|
*/ |
|
25
|
|
|
class Hungary extends AbstractProvider |
|
26
|
|
|
{ |
|
27
|
|
|
use CommonHolidays, ChristianHolidays; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Code to identify this Holiday Provider. Typically this is the ISO3166 code corresponding to the respective |
|
31
|
|
|
* country or sub-region. |
|
32
|
|
|
*/ |
|
33
|
|
|
public const ID = 'HU'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Initialize holidays for Hungary. |
|
37
|
|
|
* |
|
38
|
|
|
* @throws InvalidDateException |
|
39
|
|
|
* @throws \InvalidArgumentException |
|
40
|
|
|
* @throws UnknownLocaleException |
|
41
|
|
|
* @throws \Exception |
|
42
|
|
|
*/ |
|
43
|
|
|
public function initialize(): void |
|
44
|
|
|
{ |
|
45
|
|
|
$this->timezone = 'Europe/Budapest'; |
|
46
|
|
|
|
|
47
|
|
|
// Add common holidays |
|
48
|
|
|
$this->addHoliday($this->newYearsDay($this->year, $this->timezone, $this->locale)); |
|
49
|
|
|
$this->addHoliday($this->internationalWorkersDay($this->year, $this->timezone, $this->locale)); |
|
50
|
|
|
|
|
51
|
|
|
// Add Christian holidays |
|
52
|
|
|
if ($this->year >= 2017) { |
|
53
|
|
|
$this->addHoliday($this->goodFriday($this->year, $this->timezone, $this->locale)); |
|
54
|
|
|
} |
|
55
|
|
|
$this->addHoliday($this->easter($this->year, $this->timezone, $this->locale)); |
|
56
|
|
|
$this->addHoliday($this->easterMonday($this->year, $this->timezone, $this->locale)); |
|
57
|
|
|
$this->addHoliday($this->pentecost($this->year, $this->timezone, $this->locale, Holiday::TYPE_OBSERVANCE)); |
|
58
|
|
|
$this->addHoliday($this->pentecostMonday($this->year, $this->timezone, $this->locale)); |
|
59
|
|
|
$this->addHoliday($this->allSaintsDay($this->year, $this->timezone, $this->locale)); |
|
60
|
|
|
$this->addHoliday($this->christmasDay($this->year, $this->timezone, $this->locale)); |
|
61
|
|
|
$this->addHoliday($this->secondChristmasDay($this->year, $this->timezone, $this->locale)); |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Day of Memorial day of the 1848 Revolution |
|
65
|
|
|
*/ |
|
66
|
|
|
if ($this->year >= 1927) { |
|
67
|
|
|
$this->addHoliday(new Holiday('memorialDay1848', [ |
|
68
|
|
|
'en' => 'Memorial day of the 1848 Revolution', |
|
69
|
|
|
'hu' => 'Az 1848-as forradalom ünnepe', |
|
70
|
|
|
], new DateTime("$this->year-3-15", DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale)); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* State Foundation Day |
|
75
|
|
|
*/ |
|
76
|
|
|
if ($this->year >= 1891) { |
|
77
|
|
|
$this->addHoliday(new Holiday('stateFoundation', [ |
|
78
|
|
|
'en' => 'State Foundation Day', |
|
79
|
|
|
'hu' => 'Az államalapítás ünnepe', |
|
80
|
|
|
], new DateTime("$this->year-8-20", DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale)); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Memorial day of the 1956 Revolution |
|
85
|
|
|
*/ |
|
86
|
|
|
if ($this->year >= 1991) { |
|
87
|
|
|
$this->addHoliday(new Holiday('memorialDay1956', [ |
|
88
|
|
|
'en' => 'Memorial day of the 1956 Revolution', |
|
89
|
|
|
'hu' => 'Az 1956-os forradalom ünnepe', |
|
90
|
|
|
], new DateTime("$this->year-10-23", DateTimeZoneFactory::getDateTimeZone($this->timezone)), $this->locale)); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|