-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Holidays for Spain #49
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<?php | ||
|
||
namespace Checkdomain\Holiday\Provider; | ||
|
||
/** | ||
* Spanish holiday provider | ||
* | ||
* @author Remi Schillinger <[email protected]> | ||
* @since 2020-12-22 | ||
*/ | ||
class ES extends AbstractEaster | ||
{ | ||
const STATE_AN = 'Andalucía'; | ||
const STATE_AR = 'Aragón'; | ||
const STATE_CA = 'Cataluña'; | ||
const STATE_CE = 'Ceuta'; | ||
const STATE_CL = 'Castilla y León'; | ||
const STATE_CM = 'Castilla La Mancha'; | ||
const STATE_CN = 'Cantabria'; | ||
const STATE_CV = 'Comunidad Valenciana'; | ||
const STATE_EX = 'Extremadura'; | ||
const STATE_GA = 'Galicia'; | ||
const STATE_IB = 'Islas Baleares'; | ||
const STATE_IC = 'Islas Canarias'; | ||
const STATE_LR = 'La Rioja'; | ||
const STATE_MA = 'Madrid'; | ||
const STATE_ME = 'Melilla'; | ||
const STATE_MU = 'Murcia'; | ||
const STATE_PA = 'Principado de Asturias'; | ||
const STATE_PV = 'País Vasco'; | ||
|
||
/** | ||
* @param int $year | ||
* | ||
* @return mixed | ||
*/ | ||
public function getHolidaysByYear($year) | ||
{ | ||
$easter = $this->getEasterDates($year); | ||
|
||
$holidays = array( | ||
'01-01' => $this->createData('Año Nuevo'), | ||
'01-06' => $this->createData('Epifanía'), | ||
'02-28' => $this->createData('Día de la comunidad', array( | ||
self::STATE_AN, | ||
)), | ||
'03-01' => $this->createData('Día de la comunidad', array( | ||
self::STATE_IB, | ||
)), | ||
'03-19' => $this->createData('San José', array( | ||
self::STATE_CM, | ||
self::STATE_CV, | ||
self::STATE_GA, | ||
self::STATE_IB, | ||
self::STATE_MA, | ||
self::STATE_ME, | ||
self::STATE_MU, | ||
self::STATE_PA, | ||
)), | ||
Comment on lines
+50
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that really right? See: https://en.wikipedia.org/wiki/Public_holidays_in_Spain There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Local/regional holidays change from one year to another. It seems impossible to integrate them automatically since they are decided arbitrarily
You can see it for instance at : https://www.calendarioslaborales.com/ |
||
'04-23' => $this->createData('Día de la comunidad', array( | ||
self::STATE_AR, | ||
self::STATE_CA, | ||
self::STATE_CL, | ||
)), | ||
Comment on lines
+50
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only CL marked in Wikipedia. |
||
'05-01' => $this->createData('Fiesta del Trabajo'), | ||
'05-02' => $this->createData('Día de la comunidad', array( | ||
self::STATE_MA, | ||
)), | ||
'05-30' => $this->createData('Día de la comunidad', array( | ||
self::STATE_IC, | ||
)), | ||
'05-17' => $this->createData('Día das Letras Galegas', array( | ||
self::STATE_GA, | ||
)), | ||
'05-31' => $this->createData('Día de la comunidad', array( | ||
self::STATE_CM, | ||
)), | ||
'06-09' => $this->createData('Día de la comunidad', array( | ||
self::STATE_LR, | ||
self::STATE_MU, | ||
)), | ||
'07-25' => $this->createData('Santiago Apóstol', array( | ||
self::STATE_GA, | ||
self::STATE_MA, | ||
)), | ||
'08-15' => $this->createData('Asunción de la Virgen Maria'), | ||
'09-02' => $this->createData('Día de la comunidad', array( | ||
self::STATE_CE, | ||
)), | ||
'09-08' => $this->createData('Día de la comunidad', array( | ||
self::STATE_EX, | ||
self::STATE_PA, | ||
)), | ||
'09-11' => $this->createData('Día de la comunidad', array( | ||
self::STATE_CA, | ||
)), | ||
'09-15' => $this->createData('Día de la comunidad', array( | ||
self::STATE_CN, | ||
)), | ||
'10-09' => $this->createData('Día de la comunidad', array( | ||
self::STATE_CV, | ||
)), | ||
'10-12' => $this->createData('Fiesta Nacional de España'), | ||
'10-25' => $this->createData('Euskadi Eguna', array( | ||
self::STATE_PV, | ||
)), | ||
'11-01' => $this->createData('Todos los Santos'), | ||
'12-06' => $this->createData('Día de la Constitución'), | ||
'12-08' => $this->createData('La Inmaculada Concepción'), | ||
'12-25' => $this->createData('Navidad del Señor'), | ||
'12-26' => $this->createData('San Esteban'), | ||
// Variable dates | ||
$easter['goodFriday']->format(self::DATE_FORMAT) => $this->createData('Viernes Santo'), | ||
$easter['easterMonday']->format(self::DATE_FORMAT) => $this->createData('Lunes de Pascua', array( | ||
self::STATE_CA, | ||
self::STATE_CV, | ||
self::STATE_IB, | ||
self::STATE_PV, | ||
)), | ||
$easter['corpusChristi']->format(self::DATE_FORMAT) => $this->createData('Corpus Cristi', array( | ||
self::STATE_MA, | ||
)), | ||
); | ||
|
||
return $holidays; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace Checkdomain\Holiday\Provider; | ||
|
||
/** | ||
* Class ESTest | ||
*/ | ||
class ESTest extends AbstractTest | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->provider = new ES(); | ||
} | ||
|
||
/** | ||
* Provides some test dates and the expectation | ||
* | ||
* @return array | ||
*/ | ||
public function dateProvider() | ||
{ | ||
return array( | ||
array('2020-01-01', null, array('name' => 'Año Nuevo')), | ||
array('2020-01-06', null, array('name' => 'Epifanía')), | ||
array('2020-04-10', null, array('name' => 'Viernes Santo')), | ||
array('2021-04-02', null, array('name' => 'Viernes Santo')), | ||
array('2020-05-01', null, array('name' => 'Fiesta del Trabajo')), | ||
array('2020-08-15', null, array('name' => 'Asunción de la Virgen Maria')), | ||
array('2020-10-12', null, array('name' => 'Fiesta Nacional de España')), | ||
array('2020-11-01', null, array('name' => 'Todos los Santos')), | ||
array('2020-12-06', null, array('name' => 'Día de la Constitución')), | ||
array('2020-12-08', null, array('name' => 'La Inmaculada Concepción')), | ||
array('2020-12-25', null, array('name' => 'Navidad del Señor')), | ||
array('2020-12-26', null, array('name' => 'San Esteban')), | ||
|
||
array('2020-02-28', ES::STATE_AN, array('name' => 'Día de la comunidad')), | ||
array('2020-04-23', ES::STATE_AR, array('name' => 'Día de la comunidad')), | ||
array('2020-04-23', ES::STATE_CA, array('name' => 'Día de la comunidad')), | ||
array('2020-04-23', ES::STATE_CL, array('name' => 'Día de la comunidad')), | ||
array('2020-03-01', ES::STATE_IB, array('name' => 'Día de la comunidad')), | ||
array('2020-05-02', ES::STATE_MA, array('name' => 'Día de la comunidad')), | ||
array('2020-05-30', ES::STATE_IC, array('name' => 'Día de la comunidad')), | ||
array('2020-05-31', ES::STATE_CM, array('name' => 'Día de la comunidad')), | ||
array('2020-06-09', ES::STATE_LR, array('name' => 'Día de la comunidad')), | ||
array('2020-06-09', ES::STATE_MU, array('name' => 'Día de la comunidad')), | ||
array('2020-09-02', ES::STATE_CE, array('name' => 'Día de la comunidad')), | ||
array('2020-09-08', ES::STATE_EX, array('name' => 'Día de la comunidad')), | ||
array('2020-09-08', ES::STATE_PA, array('name' => 'Día de la comunidad')), | ||
array('2020-09-11', ES::STATE_CA, array('name' => 'Día de la comunidad')), | ||
array('2020-09-15', ES::STATE_CN, array('name' => 'Día de la comunidad')), | ||
array('2020-10-09', ES::STATE_CV, array('name' => 'Día de la comunidad')), | ||
|
||
array('2020-03-19', ES::STATE_CM, array('name' => 'San José')), | ||
array('2020-03-19', ES::STATE_CV, array('name' => 'San José')), | ||
array('2020-03-19', ES::STATE_GA, array('name' => 'San José')), | ||
array('2020-03-19', ES::STATE_IB, array('name' => 'San José')), | ||
array('2020-03-19', ES::STATE_MA, array('name' => 'San José')), | ||
array('2020-03-19', ES::STATE_ME, array('name' => 'San José')), | ||
array('2020-03-19', ES::STATE_MU, array('name' => 'San José')), | ||
array('2020-03-19', ES::STATE_PA, array('name' => 'San José')), | ||
|
||
array('2020-05-17', ES::STATE_GA, array('name' => 'Día das Letras Galegas')), | ||
|
||
array('2020-07-25', ES::STATE_GA, array('name' => 'Santiago Apóstol')), | ||
array('2020-07-25', ES::STATE_MA, array('name' => 'Santiago Apóstol')), | ||
|
||
array('2020-10-25', ES::STATE_PV, array('name' => 'Euskadi Eguna')), | ||
|
||
array('2021-04-05', ES::STATE_CA, array('name' => 'Lunes de Pascua')), | ||
array('2021-04-05', ES::STATE_CV, array('name' => 'Lunes de Pascua')), | ||
array('2021-04-05', ES::STATE_IB, array('name' => 'Lunes de Pascua')), | ||
array('2021-04-05', ES::STATE_PV, array('name' => 'Lunes de Pascua')), | ||
array('2021-04-05', ES::STATE_CA, array('name' => 'Lunes de Pascua')), | ||
array('2021-04-05', ES::STATE_CV, array('name' => 'Lunes de Pascua')), | ||
array('2021-04-05', ES::STATE_IB, array('name' => 'Lunes de Pascua')), | ||
array('2021-04-05', ES::STATE_PV, array('name' => 'Lunes de Pascua')), | ||
|
||
array('2020-06-11', ES::STATE_MA, array('name' => 'Corpus Cristi')), | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like NC is missing?
https://en.wikipedia.org/wiki/Navarre