diff --git a/README.md b/README.md index 6a8fff4..ee9e567 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,11 @@ Checkdomain/Holiday is a small library to check if a specified date is a holiday - 🇵🇱 **PL** Poland - 🇵🇹 **PT** Portugal - 🇸🇪 **SE** Sweden +- 🇷🇴 **RO** Romania +- 🇭🇺 **HU** Hungary +- 🇱🇻 **LV** Latvia +- 🇱🇹 **LT** Lithuania +- 🇪🇪 **EE** Estonia ## Your country is not supported? @@ -60,3 +65,5 @@ If you need to know all holidays for a specific country you can instantiate one ## Running Tests 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. + +To run specific test class call `php vendor/bin/phpunit --filter TestClassName` diff --git a/src/Provider/EE.php b/src/Provider/EE.php new file mode 100644 index 0000000..45d6d26 --- /dev/null +++ b/src/Provider/EE.php @@ -0,0 +1,47 @@ + + * @since 2018-03-27 + * @see https://en.wikipedia.org/wiki/Public_holidays_in_Estonia + */ +class EE extends AbstractEaster +{ + /** + * Getting non-working holidays + * + * @param int $year + * + * @return mixed + */ + public function getHolidaysByYear($year) + { + $easter = $this->getEasterDates($year); + + $holidays = array( + + '01-01' => $this->createData('uusaasta'), + '02-24' => $this->createData('iseseisvuspäev'), + '05-01' => $this->createData('kevadpüha'), + '06-23' => $this->createData('võidupüha and jaanilaupäev'), + '06-24' => $this->createData('võidupüha and jaanilaupäev'), + '08-20' => $this->createData('taasiseseisvumispäev'), + '12-24' => $this->createData('jõululaupäev'), + '12-25' => $this->createData('esimene jõulupüha'), + '12-26' => $this->createData('teine jõulupüha'), + + // Easter dates + $easter['goodFriday']->format(self::DATE_FORMAT) => $this->createData('suur reede'), + $easter['easterSunday']->format(self::DATE_FORMAT) => $this->createData('ülestõusmispühade 1. püha'), + + $easter['pentecostSunday']->format(self::DATE_FORMAT) => $this->createData('nelipühade 1. püha'), + ); + + return $holidays; + } + +} diff --git a/src/Provider/HU.php b/src/Provider/HU.php new file mode 100644 index 0000000..492df6c --- /dev/null +++ b/src/Provider/HU.php @@ -0,0 +1,53 @@ + + * @since 2018-03-27 + * @see https://en.wikipedia.org/wiki/Public_holidays_in_Hungary + */ +class HU extends AbstractEaster +{ + /** + * + * + * Getting non-working holidays + * + * @param int $year + * + * @return mixed + */ + public function getHolidaysByYear($year) + { + $easter = $this->getEasterDates($year); + + $holidays = array( + '01-01' => $this->createData('Újév'), + '03-15' => $this->createData('Nemzeti ünnep'), + '05-01' => $this->createData('A munka ünnepe'), + '08-20' => $this->createData('Az államalapítás ünnepe'), + '10-23' => $this->createData('Nemzeti ünnep'), + '11-01' => $this->createData('Mindenszentek'), + '12-25' => $this->createData('Karácsony'), + '12-26' => $this->createData('Karácsony'), + + // Easter dates + $easter['easterSunday']->format(self::DATE_FORMAT) => $this->createData('Húsvétvasárnap'), + $easter['easterMonday']->format(self::DATE_FORMAT) => $this->createData('Húsvéthétfő'), + + $easter['pentecostSunday']->format(self::DATE_FORMAT) => $this->createData('Pünkösdvasárnap'), + $easter['pentecostMonday']->format(self::DATE_FORMAT) => $this->createData('Pünkösdhétfő'), + ); + + //add holidays post 2017 + if ($year >= 2017) { + $holidays[$easter['goodFriday']->format(self::DATE_FORMAT)] = $this->createData('Nagypéntek'); + } + + return $holidays; + } + +} diff --git a/src/Provider/LT.php b/src/Provider/LT.php new file mode 100644 index 0000000..906ab89 --- /dev/null +++ b/src/Provider/LT.php @@ -0,0 +1,52 @@ + + * @since 2018-03-27 + * @see https://en.wikipedia.org/wiki/Public_holidays_in_Lithuania + */ +class LT extends AbstractEaster +{ + /** + * Getting non-working holidays + * + * @param int $year + * + * @return mixed + */ + public function getHolidaysByYear($year) + { + $easter = $this->getEasterDates($year); + + $mothersDay = date('m-d', strtotime('first Sunday of May '. $year)); + $fathersDay = date('m-d', strtotime('first Sunday of June '. $year)); + + $holidays = array( + '01-01' => $this->createData('Naujieji metai'), + '02-16' => $this->createData('Lietuvos valstybės atkūrimo diena'), + '03-11' => $this->createData('Lietuvos nepriklausomybės atkūrimo diena'), + '05-01' => $this->createData('Tarptautinė darbo diena'), + '06-24' => $this->createData('Joninės, Rasos'), + '07-06' => $this->createData('Valstybės (Lietuvos karaliaus Mindaugo karūnavimo) diena'), + '08-15' => $this->createData('Žolinė (Švč. Mergelės Marijos ėmimo į dangų diena)'), + '11-01' => $this->createData('Visų šventųjų diena (Vėlinės)'), + '12-24' => $this->createData('Šv. Kūčios'), + '12-25' => $this->createData('Šv. Kalėdos'), + '12-26' => $this->createData('Šv. Kalėdos'), + + // floating days + $mothersDay => $this->createData('Motinos diena'), + $fathersDay => $this->createData('Tėvo diena'), + + // Easter dates + $easter['easterSunday']->format(self::DATE_FORMAT) => $this->createData('Velykos'), + ); + + return $holidays; + } + +} diff --git a/src/Provider/LV.php b/src/Provider/LV.php new file mode 100644 index 0000000..141b44d --- /dev/null +++ b/src/Provider/LV.php @@ -0,0 +1,49 @@ + + * @since 2018-03-27 + * @see https://en.wikipedia.org/wiki/Public_holidays_in_Latvia + */ +class LV extends AbstractEaster +{ + /** + * Getting non-working holidays + * + * @param int $year + * + * @return mixed + */ + public function getHolidaysByYear($year) + { + $easter = $this->getEasterDates($year); + + $mothersDay = date('m-d', strtotime('second Sunday of May '. $year)); + + $holidays = array( + '01-01' => $this->createData('Jaunais Gads'), + '05-01' => $this->createData('Darba svētki'), + '05-04' => $this->createData('Latvijas Republikas Neatkarības atjaunošanas diena'), + $mothersDay => $this->createData('Mātes diena'), + '06-23' => $this->createData('Līgo Diena'), + '06-24' => $this->createData('Jāņi'), + '11-18' => $this->createData('Latvijas Republikas proklamēšanas diena'), + '12-24' => $this->createData('Ziemassvētku vakars'), + '12-25' => $this->createData('Ziemassvētki'), + '12-26' => $this->createData('Otrie Ziemassvētki'), + '12-31' => $this->createData('Vecgada vakars'), + + // Easter dates + $easter['goodFriday']->format(self::DATE_FORMAT) => $this->createData('Lielā Piektdiena'), + $easter['easterSunday']->format(self::DATE_FORMAT) => $this->createData('Lieldienas'), + $easter['easterMonday']->format(self::DATE_FORMAT) => $this->createData('Otrās Lieldienas'), + ); + + return $holidays; + } + +} diff --git a/src/Provider/RO.php b/src/Provider/RO.php new file mode 100644 index 0000000..2a32035 --- /dev/null +++ b/src/Provider/RO.php @@ -0,0 +1,53 @@ + + * @since 2018-03-27 + * @see https://en.wikipedia.org/wiki/Public_holidays_in_Romania + */ +class RO extends AbstractEaster +{ + /** + * Getting non-working holidays + * + * @param int $year + * + * @return mixed + */ + public function getHolidaysByYear($year) + { + $easter = $this->getEasterDates($year); + + $holidays = array( + '01-01' => $this->createData('Anul Nou'), + '01-02' => $this->createData('Anul Nou'), + '01-24' => $this->createData('Unirea Principatelor Române/Mica Unire'), + '05-01' => $this->createData('Ziua Muncii'), + '08-15' => $this->createData('Adormirea Maicii Domnului/Sfânta Maria Mare'), + + '11-30' => $this->createData('Sfântul Andrei'), + '12-01' => $this->createData('Ziua Națională/Ziua Marii Uniri'), + '12-25' => $this->createData('Crăciunul'), + '12-26' => $this->createData('Crăciunul'), + + // Easter dates + $easter['easterSunday']->format(self::DATE_FORMAT) => $this->createData('Paștele'), + $easter['easterMonday']->format(self::DATE_FORMAT) => $this->createData('Paștele'), + + $easter['pentecostSunday']->format(self::DATE_FORMAT) => $this->createData('Rusaliile'), + $easter['pentecostMonday']->format(self::DATE_FORMAT) => $this->createData('Rusaliile'), + ); + + //add holidays post 2017 + if ($year >= 2017) { + $holidays['06-01'] = $this->createData('Ziua Copilului'); + } + + return $holidays; + } + +} diff --git a/test/Provider/EETest.php b/test/Provider/EETest.php new file mode 100644 index 0000000..233a9ce --- /dev/null +++ b/test/Provider/EETest.php @@ -0,0 +1,54 @@ +provider = new EE(); + } + + /** + * Provides some test dates and the expectation + * + * vendor/bin/phpunit --filter EETest + * + * @return array + */ + public function dateProvider() + { + return array( + array('2018-01-03', null, null), + array('2018-03-21', null, null), + array('2018-03-22', null, null), + array('2018-12-27', null, null), + + array('2018-01-01', null, array('name' => 'uusaasta')), + array('2018-02-24', null, array('name' => 'iseseisvuspäev')), + array('2018-05-01', null, array('name' => 'kevadpüha')), + array('2018-06-23', null, array('name' => 'võidupüha and jaanilaupäev')), + array('2018-06-24', null, array('name' => 'võidupüha and jaanilaupäev')), + array('2018-08-20', null, array('name' => 'taasiseseisvumispäev')), + array('2018-12-24', null, array('name' => 'jõululaupäev')), + array('2018-12-25', null, array('name' => 'esimene jõulupüha')), + array('2018-12-26', null, array('name' => 'teine jõulupüha')), + + // Easter dates 2018 + array('2018-03-30', null, array('name' => 'suur reede')), + array('2018-04-01', null, array('name' => 'ülestõusmispühade 1. püha')), + array('2018-05-20', null, array('name' => 'nelipühade 1. püha')), + + // Easter dates 2019 + array('2019-04-19', null, array('name' => 'suur reede')), + array('2019-04-21', null, array('name' => 'ülestõusmispühade 1. püha')), + array('2019-06-09', null, array('name' => 'nelipühade 1. püha')), + ); + } +} diff --git a/test/Provider/HUTest.php b/test/Provider/HUTest.php new file mode 100644 index 0000000..df97830 --- /dev/null +++ b/test/Provider/HUTest.php @@ -0,0 +1,56 @@ +provider = new HU(); + } + + /** + * Provides some test dates and the expectation + * + * vendor/bin/phpunit --filter HUTest + * + * @return array + */ + public function dateProvider() + { + return array( + array('2018-01-03', null, null), + array('2018-03-21', null, null), + array('2018-03-22', null, null), + array('2018-12-27', null, null), + + array('2018-01-01', null, array('name' => 'Újév')), + array('2018-03-15', null, array('name' => 'Nemzeti ünnep')), + array('2018-05-01', null, array('name' => 'A munka ünnepe')), + array('2018-08-20', null, array('name' => 'Az államalapítás ünnepe')), + array('2018-10-23', null, array('name' => 'Nemzeti ünnep')), + array('2018-11-01', null, array('name' => 'Mindenszentek')), + array('2018-12-25', null, array('name' => 'Karácsony')), + array('2018-12-26', null, array('name' => 'Karácsony')), + + + // Easter dates 2018 + array('2018-04-01', null, array('name' => 'Húsvétvasárnap')), + array('2018-04-02', null, array('name' => 'Húsvéthétfő')), + array('2018-05-20', null, array('name' => 'Pünkösdvasárnap')), + array('2018-05-21', null, array('name' => 'Pünkösdhétfő')), + + // Easter dates 2019 + array('2019-04-21', null, array('name' => 'Húsvétvasárnap')), + array('2019-04-22', null, array('name' => 'Húsvéthétfő')), + array('2019-06-09', null, array('name' => 'Pünkösdvasárnap')), + array('2019-06-10', null, array('name' => 'Pünkösdhétfő')), + ); + } +} diff --git a/test/Provider/LTTest.php b/test/Provider/LTTest.php new file mode 100644 index 0000000..ec62188 --- /dev/null +++ b/test/Provider/LTTest.php @@ -0,0 +1,58 @@ +provider = new LT(); + } + + /** + * Provides some test dates and the expectation + * + * vendor/bin/phpunit --filter LTTest + * + * @return array + */ + public function dateProvider() + { + return array( + array('2018-01-03', null, null), + array('2018-03-21', null, null), + array('2018-03-22', null, null), + array('2018-12-27', null, null), + + array('2018-01-01', null, array('name' => 'Naujieji metai')), + array('2018-02-16', null, array('name' => 'Lietuvos valstybės atkūrimo diena')), + array('2018-03-11', null, array('name' => 'Lietuvos nepriklausomybės atkūrimo diena')), + array('2018-05-01', null, array('name' => 'Tarptautinė darbo diena')), + array('2018-06-24', null, array('name' => 'Joninės, Rasos')), + array('2018-07-06', null, array('name' => 'Valstybės (Lietuvos karaliaus Mindaugo karūnavimo) diena')), + array('2018-08-15', null, array('name' => 'Žolinė (Švč. Mergelės Marijos ėmimo į dangų diena)')), + array('2018-11-01', null, array('name' => 'Visų šventųjų diena (Vėlinės)')), + array('2018-12-24', null, array('name' => 'Šv. Kūčios')), + array('2018-12-25', null, array('name' => 'Šv. Kalėdos')), + array('2018-12-26', null, array('name' => 'Šv. Kalėdos')), + + // Motinos diena floating holiday (First Sunday in May) + array('2018-05-06', null, array('name' => 'Motinos diena')), + + // Tėvo diena floating holiday (First Sunday in June) + array('2018-06-03', null, array('name' => 'Tėvo diena')), + + // Easter dates 2018 + array('2018-04-01', null, array('name' => 'Velykos')), + + // Easter dates 2019 + array('2019-04-21', null, array('name' => 'Velykos')), + ); + } +} diff --git a/test/Provider/LVTest.php b/test/Provider/LVTest.php new file mode 100644 index 0000000..7c9adfc --- /dev/null +++ b/test/Provider/LVTest.php @@ -0,0 +1,59 @@ +provider = new LV(); + } + + /** + * Provides some test dates and the expectation + * + * vendor/bin/phpunit --filter LVTest + * + * @return array + */ + public function dateProvider() + { + return array( + array('2018-01-03', null, null), + array('2018-03-21', null, null), + array('2018-03-22', null, null), + array('2018-12-27', null, null), + + array('2018-01-01', null, array('name' => 'Jaunais Gads')), + array('2018-05-01', null, array('name' => 'Darba svētki')), + array('2018-05-04', null, array('name' => 'Latvijas Republikas Neatkarības atjaunošanas diena')), + + array('2018-06-23', null, array('name' => 'Līgo Diena')), + array('2018-06-24', null, array('name' => 'Jāņi')), + array('2018-11-18', null, array('name' => 'Latvijas Republikas proklamēšanas diena')), + array('2018-12-24', null, array('name' => 'Ziemassvētku vakars')), + array('2018-12-25', null, array('name' => 'Ziemassvētki')), + array('2018-12-26', null, array('name' => 'Otrie Ziemassvētki')), + array('2018-12-31', null, array('name' => 'Vecgada vakars')), + + // Mātes diena floating holiday (Second Sunday of May) + array('2018-05-13', null, array('name' => 'Mātes diena')), + + // Easter dates 2018 + array('2018-03-30', null, array('name' => 'Lielā Piektdiena')), + array('2018-04-01', null, array('name' => 'Lieldienas')), + array('2018-04-02', null, array('name' => 'Otrās Lieldienas')), + + // Easter dates 2019 + array('2019-04-19', null, array('name' => 'Lielā Piektdiena')), + array('2019-04-21', null, array('name' => 'Lieldienas')), + array('2019-04-22', null, array('name' => 'Otrās Lieldienas')), + ); + } +} diff --git a/test/Provider/ROTest.php b/test/Provider/ROTest.php new file mode 100644 index 0000000..ae66ea8 --- /dev/null +++ b/test/Provider/ROTest.php @@ -0,0 +1,55 @@ +provider = new RO(); + } + + /** + * Provides some test dates and the expectation + * + * @return array + */ + public function dateProvider() + { + return array( + array('2018-01-03', null, null), + array('2018-03-21', null, null), + array('2018-03-22', null, null), + array('2018-12-27', null, null), + + array('2018-01-01', null, array('name' => 'Anul Nou')), + array('2018-01-02', null, array('name' => 'Anul Nou')), + array('2018-01-24', null, array('name' => 'Unirea Principatelor Române/Mica Unire')), + array('2018-05-01', null, array('name' => 'Ziua Muncii')), + array('2018-06-01', null, array('name' => 'Ziua Copilului')), + array('2018-08-15', null, array('name' => 'Adormirea Maicii Domnului/Sfânta Maria Mare')), + array('2018-11-30', null, array('name' => 'Sfântul Andrei')), + array('2018-12-01', null, array('name' => 'Ziua Națională/Ziua Marii Uniri')), + array('2018-12-25', null, array('name' => 'Crăciunul')), + array('2018-12-26', null, array('name' => 'Crăciunul')), + + // Easter dates 2018 + array('2018-04-01', null, array('name' => 'Paștele')), + array('2018-04-02', null, array('name' => 'Paștele')), + array('2018-05-20', null, array('name' => 'Rusaliile')), + array('2018-05-21', null, array('name' => 'Rusaliile')), + + // Easter dates 2019 + array('2019-04-21', null, array('name' => 'Paștele')), + array('2019-04-22', null, array('name' => 'Paștele')), + array('2019-06-09', null, array('name' => 'Rusaliile')), + array('2019-06-10', null, array('name' => 'Rusaliile')), + ); + } +}