Skip to content

Commit 5cc1cf5

Browse files
Merge pull request #26 from agilov/ROLVLTETHU
Added 5 countries: RO, LV, LT, EE, HU
2 parents ce9294e + 95d1daf commit 5cc1cf5

File tree

11 files changed

+543
-0
lines changed

11 files changed

+543
-0
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ Checkdomain/Holiday is a small library to check if a specified date is a holiday
1515
- 🇵🇱 **PL** Poland
1616
- 🇵🇹 **PT** Portugal
1717
- 🇸🇪 **SE** Sweden
18+
- 🇷🇴 **RO** Romania
19+
- 🇭🇺 **HU** Hungary
20+
- 🇱🇻 **LV** Latvia
21+
- 🇱🇹 **LT** Lithuania
22+
- 🇪🇪 **EE** Estonia
1823

1924
## Your country is not supported?
2025

@@ -60,3 +65,5 @@ If you need to know all holidays for a specific country you can instantiate one
6065
## Running Tests
6166

6267
Run a `php composer.phar install` command in the base directory to install the `phpunit` dependency. After that you can simply call `php vendor/bin/phpunit` to run the test suite.
68+
69+
To run specific test class call `php vendor/bin/phpunit --filter TestClassName`

src/Provider/EE.php

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace Checkdomain\Holiday\Provider;
4+
5+
/**
6+
* Estonian non-working holidays provider
7+
*
8+
* @author Roman Agilov <[email protected]>
9+
* @since 2018-03-27
10+
* @see https://en.wikipedia.org/wiki/Public_holidays_in_Estonia
11+
*/
12+
class EE extends AbstractEaster
13+
{
14+
/**
15+
* Getting non-working holidays
16+
*
17+
* @param int $year
18+
*
19+
* @return mixed
20+
*/
21+
public function getHolidaysByYear($year)
22+
{
23+
$easter = $this->getEasterDates($year);
24+
25+
$holidays = array(
26+
27+
'01-01' => $this->createData('uusaasta'),
28+
'02-24' => $this->createData('iseseisvuspäev'),
29+
'05-01' => $this->createData('kevadpüha'),
30+
'06-23' => $this->createData('võidupüha and jaanilaupäev'),
31+
'06-24' => $this->createData('võidupüha and jaanilaupäev'),
32+
'08-20' => $this->createData('taasiseseisvumispäev'),
33+
'12-24' => $this->createData('jõululaupäev'),
34+
'12-25' => $this->createData('esimene jõulupüha'),
35+
'12-26' => $this->createData('teine jõulupüha'),
36+
37+
// Easter dates
38+
$easter['goodFriday']->format(self::DATE_FORMAT) => $this->createData('suur reede'),
39+
$easter['easterSunday']->format(self::DATE_FORMAT) => $this->createData('ülestõusmispühade 1. püha'),
40+
41+
$easter['pentecostSunday']->format(self::DATE_FORMAT) => $this->createData('nelipühade 1. püha'),
42+
);
43+
44+
return $holidays;
45+
}
46+
47+
}

src/Provider/HU.php

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace Checkdomain\Holiday\Provider;
4+
5+
/**
6+
* Hungarian non-working holidays provider
7+
*
8+
* @author Roman Agilov <[email protected]>
9+
* @since 2018-03-27
10+
* @see https://en.wikipedia.org/wiki/Public_holidays_in_Hungary
11+
*/
12+
class HU extends AbstractEaster
13+
{
14+
/**
15+
*
16+
*
17+
* Getting non-working holidays
18+
*
19+
* @param int $year
20+
*
21+
* @return mixed
22+
*/
23+
public function getHolidaysByYear($year)
24+
{
25+
$easter = $this->getEasterDates($year);
26+
27+
$holidays = array(
28+
'01-01' => $this->createData('Újév'),
29+
'03-15' => $this->createData('Nemzeti ünnep'),
30+
'05-01' => $this->createData('A munka ünnepe'),
31+
'08-20' => $this->createData('Az államalapítás ünnepe'),
32+
'10-23' => $this->createData('Nemzeti ünnep'),
33+
'11-01' => $this->createData('Mindenszentek'),
34+
'12-25' => $this->createData('Karácsony'),
35+
'12-26' => $this->createData('Karácsony'),
36+
37+
// Easter dates
38+
$easter['easterSunday']->format(self::DATE_FORMAT) => $this->createData('Húsvétvasárnap'),
39+
$easter['easterMonday']->format(self::DATE_FORMAT) => $this->createData('Húsvéthétfő'),
40+
41+
$easter['pentecostSunday']->format(self::DATE_FORMAT) => $this->createData('Pünkösdvasárnap'),
42+
$easter['pentecostMonday']->format(self::DATE_FORMAT) => $this->createData('Pünkösdhétfő'),
43+
);
44+
45+
//add holidays post 2017
46+
if ($year >= 2017) {
47+
$holidays[$easter['goodFriday']->format(self::DATE_FORMAT)] = $this->createData('Nagypéntek');
48+
}
49+
50+
return $holidays;
51+
}
52+
53+
}

src/Provider/LT.php

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
namespace Checkdomain\Holiday\Provider;
4+
5+
/**
6+
* Lithuanian non-working holidays provider
7+
*
8+
* @author Roman Agilov <[email protected]>
9+
* @since 2018-03-27
10+
* @see https://en.wikipedia.org/wiki/Public_holidays_in_Lithuania
11+
*/
12+
class LT extends AbstractEaster
13+
{
14+
/**
15+
* Getting non-working holidays
16+
*
17+
* @param int $year
18+
*
19+
* @return mixed
20+
*/
21+
public function getHolidaysByYear($year)
22+
{
23+
$easter = $this->getEasterDates($year);
24+
25+
$mothersDay = date('m-d', strtotime('first Sunday of May '. $year));
26+
$fathersDay = date('m-d', strtotime('first Sunday of June '. $year));
27+
28+
$holidays = array(
29+
'01-01' => $this->createData('Naujieji metai'),
30+
'02-16' => $this->createData('Lietuvos valstybės atkūrimo diena'),
31+
'03-11' => $this->createData('Lietuvos nepriklausomybės atkūrimo diena'),
32+
'05-01' => $this->createData('Tarptautinė darbo diena'),
33+
'06-24' => $this->createData('Joninės, Rasos'),
34+
'07-06' => $this->createData('Valstybės (Lietuvos karaliaus Mindaugo karūnavimo) diena'),
35+
'08-15' => $this->createData('Žolinė (Švč. Mergelės Marijos ėmimo į dangų diena)'),
36+
'11-01' => $this->createData('Visų šventųjų diena (Vėlinės)'),
37+
'12-24' => $this->createData('Šv. Kūčios'),
38+
'12-25' => $this->createData('Šv. Kalėdos'),
39+
'12-26' => $this->createData('Šv. Kalėdos'),
40+
41+
// floating days
42+
$mothersDay => $this->createData('Motinos diena'),
43+
$fathersDay => $this->createData('Tėvo diena'),
44+
45+
// Easter dates
46+
$easter['easterSunday']->format(self::DATE_FORMAT) => $this->createData('Velykos'),
47+
);
48+
49+
return $holidays;
50+
}
51+
52+
}

src/Provider/LV.php

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace Checkdomain\Holiday\Provider;
4+
5+
/**
6+
* Latvian non-working holidays provider
7+
*
8+
* @author Roman Agilov <[email protected]>
9+
* @since 2018-03-27
10+
* @see https://en.wikipedia.org/wiki/Public_holidays_in_Latvia
11+
*/
12+
class LV extends AbstractEaster
13+
{
14+
/**
15+
* Getting non-working holidays
16+
*
17+
* @param int $year
18+
*
19+
* @return mixed
20+
*/
21+
public function getHolidaysByYear($year)
22+
{
23+
$easter = $this->getEasterDates($year);
24+
25+
$mothersDay = date('m-d', strtotime('second Sunday of May '. $year));
26+
27+
$holidays = array(
28+
'01-01' => $this->createData('Jaunais Gads'),
29+
'05-01' => $this->createData('Darba svētki'),
30+
'05-04' => $this->createData('Latvijas Republikas Neatkarības atjaunošanas diena'),
31+
$mothersDay => $this->createData('Mātes diena'),
32+
'06-23' => $this->createData('Līgo Diena'),
33+
'06-24' => $this->createData('Jāņi'),
34+
'11-18' => $this->createData('Latvijas Republikas proklamēšanas diena'),
35+
'12-24' => $this->createData('Ziemassvētku vakars'),
36+
'12-25' => $this->createData('Ziemassvētki'),
37+
'12-26' => $this->createData('Otrie Ziemassvētki'),
38+
'12-31' => $this->createData('Vecgada vakars'),
39+
40+
// Easter dates
41+
$easter['goodFriday']->format(self::DATE_FORMAT) => $this->createData('Lielā Piektdiena'),
42+
$easter['easterSunday']->format(self::DATE_FORMAT) => $this->createData('Lieldienas'),
43+
$easter['easterMonday']->format(self::DATE_FORMAT) => $this->createData('Otrās Lieldienas'),
44+
);
45+
46+
return $holidays;
47+
}
48+
49+
}

src/Provider/RO.php

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace Checkdomain\Holiday\Provider;
4+
5+
/**
6+
* Romanian non-working holidays provider
7+
*
8+
* @author Roman Agilov <[email protected]>
9+
* @since 2018-03-27
10+
* @see https://en.wikipedia.org/wiki/Public_holidays_in_Romania
11+
*/
12+
class RO extends AbstractEaster
13+
{
14+
/**
15+
* Getting non-working holidays
16+
*
17+
* @param int $year
18+
*
19+
* @return mixed
20+
*/
21+
public function getHolidaysByYear($year)
22+
{
23+
$easter = $this->getEasterDates($year);
24+
25+
$holidays = array(
26+
'01-01' => $this->createData('Anul Nou'),
27+
'01-02' => $this->createData('Anul Nou'),
28+
'01-24' => $this->createData('Unirea Principatelor Române/Mica Unire'),
29+
'05-01' => $this->createData('Ziua Muncii'),
30+
'08-15' => $this->createData('Adormirea Maicii Domnului/Sfânta Maria Mare'),
31+
32+
'11-30' => $this->createData('Sfântul Andrei'),
33+
'12-01' => $this->createData('Ziua Națională/Ziua Marii Uniri'),
34+
'12-25' => $this->createData('Crăciunul'),
35+
'12-26' => $this->createData('Crăciunul'),
36+
37+
// Easter dates
38+
$easter['easterSunday']->format(self::DATE_FORMAT) => $this->createData('Paștele'),
39+
$easter['easterMonday']->format(self::DATE_FORMAT) => $this->createData('Paștele'),
40+
41+
$easter['pentecostSunday']->format(self::DATE_FORMAT) => $this->createData('Rusaliile'),
42+
$easter['pentecostMonday']->format(self::DATE_FORMAT) => $this->createData('Rusaliile'),
43+
);
44+
45+
//add holidays post 2017
46+
if ($year >= 2017) {
47+
$holidays['06-01'] = $this->createData('Ziua Copilului');
48+
}
49+
50+
return $holidays;
51+
}
52+
53+
}

test/Provider/EETest.php

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
namespace Checkdomain\Holiday\Provider;
4+
5+
/**
6+
* Class EETest
7+
*/
8+
class EETest extends AbstractTest
9+
{
10+
/**
11+
* {@inheritDoc}
12+
*/
13+
public function setUp()
14+
{
15+
$this->provider = new EE();
16+
}
17+
18+
/**
19+
* Provides some test dates and the expectation
20+
*
21+
* vendor/bin/phpunit --filter EETest
22+
*
23+
* @return array
24+
*/
25+
public function dateProvider()
26+
{
27+
return array(
28+
array('2018-01-03', null, null),
29+
array('2018-03-21', null, null),
30+
array('2018-03-22', null, null),
31+
array('2018-12-27', null, null),
32+
33+
array('2018-01-01', null, array('name' => 'uusaasta')),
34+
array('2018-02-24', null, array('name' => 'iseseisvuspäev')),
35+
array('2018-05-01', null, array('name' => 'kevadpüha')),
36+
array('2018-06-23', null, array('name' => 'võidupüha and jaanilaupäev')),
37+
array('2018-06-24', null, array('name' => 'võidupüha and jaanilaupäev')),
38+
array('2018-08-20', null, array('name' => 'taasiseseisvumispäev')),
39+
array('2018-12-24', null, array('name' => 'jõululaupäev')),
40+
array('2018-12-25', null, array('name' => 'esimene jõulupüha')),
41+
array('2018-12-26', null, array('name' => 'teine jõulupüha')),
42+
43+
// Easter dates 2018
44+
array('2018-03-30', null, array('name' => 'suur reede')),
45+
array('2018-04-01', null, array('name' => 'ülestõusmispühade 1. püha')),
46+
array('2018-05-20', null, array('name' => 'nelipühade 1. püha')),
47+
48+
// Easter dates 2019
49+
array('2019-04-19', null, array('name' => 'suur reede')),
50+
array('2019-04-21', null, array('name' => 'ülestõusmispühade 1. püha')),
51+
array('2019-06-09', null, array('name' => 'nelipühade 1. püha')),
52+
);
53+
}
54+
}

test/Provider/HUTest.php

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace Checkdomain\Holiday\Provider;
4+
5+
/**
6+
* Class HUTest
7+
*/
8+
class HUTest extends AbstractTest
9+
{
10+
/**
11+
* {@inheritDoc}
12+
*/
13+
public function setUp()
14+
{
15+
$this->provider = new HU();
16+
}
17+
18+
/**
19+
* Provides some test dates and the expectation
20+
*
21+
* vendor/bin/phpunit --filter HUTest
22+
*
23+
* @return array
24+
*/
25+
public function dateProvider()
26+
{
27+
return array(
28+
array('2018-01-03', null, null),
29+
array('2018-03-21', null, null),
30+
array('2018-03-22', null, null),
31+
array('2018-12-27', null, null),
32+
33+
array('2018-01-01', null, array('name' => 'Újév')),
34+
array('2018-03-15', null, array('name' => 'Nemzeti ünnep')),
35+
array('2018-05-01', null, array('name' => 'A munka ünnepe')),
36+
array('2018-08-20', null, array('name' => 'Az államalapítás ünnepe')),
37+
array('2018-10-23', null, array('name' => 'Nemzeti ünnep')),
38+
array('2018-11-01', null, array('name' => 'Mindenszentek')),
39+
array('2018-12-25', null, array('name' => 'Karácsony')),
40+
array('2018-12-26', null, array('name' => 'Karácsony')),
41+
42+
43+
// Easter dates 2018
44+
array('2018-04-01', null, array('name' => 'Húsvétvasárnap')),
45+
array('2018-04-02', null, array('name' => 'Húsvéthétfő')),
46+
array('2018-05-20', null, array('name' => 'Pünkösdvasárnap')),
47+
array('2018-05-21', null, array('name' => 'Pünkösdhétfő')),
48+
49+
// Easter dates 2019
50+
array('2019-04-21', null, array('name' => 'Húsvétvasárnap')),
51+
array('2019-04-22', null, array('name' => 'Húsvéthétfő')),
52+
array('2019-06-09', null, array('name' => 'Pünkösdvasárnap')),
53+
array('2019-06-10', null, array('name' => 'Pünkösdhétfő')),
54+
);
55+
}
56+
}

0 commit comments

Comments
 (0)