diff --git a/README.md b/README.md index c536283..bfdbdef 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,35 @@ holidays common to all states). Before selecting a region the list of holidays is empty so `isHoliday` will return `false` for any date. +#### getYearHolidays + +Get the holiday dates list for a given year: + +```php +Carbon::setHolidaysRegion('us'); + +foreach (Carbon::getYearHolidays(2020) as $id => $holiday) { + echo $holiday->getHolidayName().': '.$holiday->format('l, F j, Y')."\n"; +} + +// If Carbon::getYearHolidays() is called without argument, current year is used instead. +``` + +It will output: + +```text +New Year: Wednesday, January 1, 2020 +Martin Luther King Jr. Day: Monday, January 20, 2020 +Washington’s Birthday: Monday, February 17, 2020 +Memorial Day: Monday, May 25, 2020 +Independence Day: Monday, July 6, 2020 +Labor Day: Monday, September 7, 2020 +Columbus Day: Monday, October 12, 2020 +Day of the veterans: Wednesday, November 11, 2020 +Thanksgiving: Thursday, November 26, 2020 +Christmas: Friday, December 25, 2020 +``` + #### getHolidays This method allow you to get the holiday list for a diff --git a/src/Cmixin/HolidayNames/en.php b/src/Cmixin/HolidayNames/en.php index 6395a7d..95fc060 100644 --- a/src/Cmixin/HolidayNames/en.php +++ b/src/Cmixin/HolidayNames/en.php @@ -492,7 +492,7 @@ '09-17' => 'National Hero Day', '03-24' => 'Day of Remembrance for Truth and Justice', 'substitutes-03-24-if-tuesday-then-previous-monday-if-thursday-then-next-friday' => 'Bridge Day', - 'veterans-day' => 'Day of the veterans and the fallen in Malvinas War', + 'veterans-day' => 'Day of the veterans', 'substitutes-04-02-if-tuesday-then-previous-monday-if-thursday-then-next-friday' => 'Bridge Day', 'substitutes-05-01-if-tuesday-then-previous-monday-if-thursday-then-next-friday' => 'Bridge Day', '05-25' => 'Day of the First National Government', @@ -1017,7 +1017,6 @@ '1st-monday-in-august' => 'August Monday', '1st-thursday-in-august' => 'August Thursday', '2nd-saturday-in-october' => 'Translator\'s Day', - '04-02' => 'Day of the veterans and the fallen in Malvinas War', '3rd-monday-in-august' => 'Anniversary of the death of General José de San Martín', '10-12-if-tuesday,wednesday-then-previous-monday-if-thursday,friday,saturday,sunday-then-next-monday' => 'Day of Respect for Cultural Diversity', '4th-monday-in-november' => 'Day of National Sovereignty', diff --git a/src/Cmixin/Holidays/ar-national.php b/src/Cmixin/Holidays/ar-national.php index 9f7644d..a69278e 100644 --- a/src/Cmixin/Holidays/ar-national.php +++ b/src/Cmixin/Holidays/ar-national.php @@ -1,28 +1,28 @@ '01-01', - 'easter-48' => '= easter -48', - 'easter-47' => '= easter -47', - '03-24' => '03-24', - 'substitutes-03-24' => '= 03-24 if Tuesday then previous Monday and if Thursday then next Friday', - 'easter-3' => '= easter -3', - 'easter-2' => '= easter -2', - '04-02' => '04-02', - 'substitutes-04-02' => '= 04-02 if Tuesday then previous Monday and if Thursday then next Friday', - '05-01' => '05-01', - 'substitutes-05-01' => '= 05-01 if Tuesday then previous Monday and if Thursday then next Friday', - '05-25' => '05-25', - 'substitutes-05-25' => '= 05-25 if Tuesday then previous Monday and if Thursday then next Friday', - '06-20' => '06-20', - 'substitutes-06-20' => '= 06-20 if Tuesday then previous Monday and if Thursday then next Friday', - '07-09' => '07-09', - '3rd-monday-of-august' => '= third Monday of August', - '10-12' => '= 10-12 if Tuesday,Wednesday then previous Monday and if Thursday,Friday,Saturday,Sunday then next Monday', - '4th-monday-of-november' => '= fourth Monday of November', - '12-08' => '12-08', - 'substitutes-12-08' => '= 12-08 if Tuesday then previous Monday and if Thursday then next Friday', - 'substitutes-12-24' => '= 12-24 if Tuesday then previous Monday', - 'christmas' => '12-25', - 'substitutes-12-25' => '= 12-25 if Thursday then next Friday', + 'new-year' => '01-01', + 'easter-48' => '= easter -48', + 'easter-47' => '= easter -47', + '03-24' => '03-24', + 'substitutes-03-24' => '= 03-24 if Tuesday then previous Monday and if Thursday then next Friday', + 'easter-3' => '= easter -3', + 'easter-2' => '= easter -2', + 'day-of-the-veterans-and-the-fallen-of-malvinas-war' => '04-02', + 'substitutes-04-02' => '= 04-02 if Tuesday then previous Monday and if Thursday then next Friday', + '05-01' => '05-01', + 'substitutes-05-01' => '= 05-01 if Tuesday then previous Monday and if Thursday then next Friday', + '05-25' => '05-25', + 'substitutes-05-25' => '= 05-25 if Tuesday then previous Monday and if Thursday then next Friday', + '06-20' => '06-20', + 'substitutes-06-20' => '= 06-20 if Tuesday then previous Monday and if Thursday then next Friday', + '07-09' => '07-09', + '3rd-monday-of-august' => '= third Monday of August', + '10-12' => '= 10-12 if Tuesday,Wednesday then previous Monday and if Thursday,Friday,Saturday,Sunday then next Monday', + '4th-monday-of-november' => '= fourth Monday of November', + '12-08' => '12-08', + 'substitutes-12-08' => '= 12-08 if Tuesday then previous Monday and if Thursday then next Friday', + 'substitutes-12-24' => '= 12-24 if Tuesday then previous Monday', + 'christmas' => '12-25', + 'substitutes-12-25' => '= 12-25 if Thursday then next Friday', ); diff --git a/tests/Cmixin/ListsTest.php b/tests/Cmixin/ListsTest.php index 3b98d76..474dbdf 100644 --- a/tests/Cmixin/ListsTest.php +++ b/tests/Cmixin/ListsTest.php @@ -93,4 +93,28 @@ public function testNamesInvalidity() self::assertSame('Christmas', $translations['christmas']); } + + public function testGetYearHolidays() + { + Carbon::setHolidaysRegion('us'); + + $days = array(); + + foreach (Carbon::getYearHolidays(2020) as $id => $holiday) { + $days[] = $holiday->getHolidayName().': '.$holiday->format('l, F j, Y'); + } + + self::assertSame(array( + 'New Year: Wednesday, January 1, 2020', + 'Martin Luther King Jr. Day: Monday, January 20, 2020', + 'Washington’s Birthday: Monday, February 17, 2020', + 'Memorial Day: Monday, May 25, 2020', + 'Independence Day: Monday, July 6, 2020', + 'Labor Day: Monday, September 7, 2020', + 'Columbus Day: Monday, October 12, 2020', + 'Day of the veterans: Wednesday, November 11, 2020', + 'Thanksgiving: Thursday, November 26, 2020', + 'Christmas: Friday, December 25, 2020', + ), $days); + } }