vacanza / python-holidays

Generate and work with holidays in Python
https://pypi.org/project/holidays
MIT License
1.44k stars 458 forks source link

Holidays in Portugal #331

Open goncaloperes opened 4 years ago

goncaloperes commented 4 years ago

Even though in Portugal there are nationwide holidays, others are regional or municipal (depending on the city).

If one runs the following script, to access the holidays in Portugal plus extended days most people have off:

from datetime import date
import holidays
for date, name in sorted(holidays.PTE(years=2020).items()):
    print(date, name)

One gets the following list:

2020-01-01 Ano Novo 2020-02-25 Carnaval 2020-04-10 Sexta-feira Santa 2020-04-12 Páscoa 2020-04-25 Dia da Liberdade 2020-05-01 Dia do Trabalhador 2020-06-10 Dia de Portugal 2020-06-11 Corpo de Deus 2020-06-13 Dia de Santo António 2020-08-15 Assunção de Nossa Senhora 2020-10-05 Implantação da República 2020-11-01 Dia de Todos os Santos 2020-12-01 Restauração da Independência 2020-12-08 Imaculada Conceição 2020-12-24 Véspera de Natal 2020-12-25 Dia de Natal 2020-12-26 26 de Dezembro 2020-12-31 Véspera de Ano Novo

I have seen that the general/national holidays for Portugal are missing, here is its list:

Date Name
1 of January Ano Novo
Tuesday (between 3 of February and 9 of March) Entrudo/Carnaval
Friday (between 20 of March and 23 of April) Sexta-Feira Santa
Sunday (between 22 of March and 25 of April) Páscoa
25 of April Dia da Liberdade
1 of May Dia do Trabalhador
Thursday (between 21 of May and 24 of June) Corpo de Deus
10 of June Dia de Portugal
15 of August Assunção de Nossa Senhora
5 of October Implantação da República
1 of November Todos os Santos
1 of December Restauração da Independência
8 of December Imaculada Conceição
25 of December Natal

As one can see, it is slightly different than the one above, as the first one considers some municipal holidays. Here is a detailed list of the holidays in Portugal, in their specific months.

goncaloperes commented 4 years ago

Additional Notes: • The state has been giving "Entrudo" since 1978, but there were some exceptions: 1993 and 2012–2015. • Corpus Cristus and Implantação da República were suspended between 2013 and 2015 (inclusive).

pmpbaptista commented 1 year ago

I may suggest adding the 18 district holidays: Aveiro, Beja, Braga, Bragança, Castelo Branco, Coimbra, Évora, Faro, Guarda, Leiria, Lisboa, Portalegre, Porto, Santarém, Setúbal, Viana do Castelo, Vila Real e Viseu. I can create a PR with this addition if you agree @dr-prodigy

To get more granular, we would need to add the 318 municipal holidays ... that would take considerably more time to implement.

dr-prodigy commented 1 year ago

@Nalguedo it sounds like a good plan.. I definitely agree on it! If you wish to implement this first version, please do and I'll be happy to include it.. then there's always time to improve and proceed with the other 300 :-) Thank you very much!

PPsyrius commented 1 year ago

@dr-prodigy This is now solved with the latest release.

arkid15r commented 1 year ago

Not sure if we want to keep it open to track progress on adding those ~300 holidays mentioned by @goncaloperes and @pmpbaptista

pmpbaptista commented 1 year ago

It makes sense to keep it open ;)

JarbasAl commented 2 months ago

I was about to open an issue about Municipal Holidays, a full list is missing in english wikipedia but can be found in the portuguese page https://pt.wikipedia.org/wiki/Feriados_em_Portugal

I can work on this and send a PR, but I am not sure how to go about it. Currently the code allows the regions defined in https://en.wikipedia.org/wiki/ISO_3166-2:PT

How would I add the municipalities under the subdivisions? Once this is clear I can implement the dates from the wiki page linked above

arkid15r commented 2 months ago

Hi @JarbasAl, Thanks for your willingness to help with this!

Currently, holidays code does not natively support handling of parent subdivisions. The subdivisions list is flat so you would need to add municipalities subdivisions just on the same level as the current once.

What's really complicated is the fact that ISO 3166 knows nothing about Portugal subdivisions besides what we already have.

As the next holidays version (v1) is going to reflect ISO 3166 classification this might be a problem. I guess we could have something like extras module for such cases.

So you have a couple of options here:

You can find current v1 code for PT here.

JarbasAl commented 2 months ago

I did some searching and found that we have 3-letter codes, perhaps these could be used as identifiers?

https://pt.wikipedia.org/wiki/C%C3%B3digo_municipal

I gathered them in csv format here https://gist.github.com/JarbasAl/00ac648935e964a795e9b9fe4585c2a5

source: https://files.dre.pt/1s/1998/07/161a00/33893408.pdf (page 16)

there is also the NUTS codes, but those are not granular enough, posting for reference only

https://pt.wikipedia.org/wiki/NUTS_de_Portugal https://pt.wikipedia.org/wiki/Lista_de_munic%C3%ADpios_de_Portugal_por_NUTS,_distritos_e_ilhas

arkid15r commented 2 months ago

I've tasked AI to do some work in this direction but not sure about the quality of the result as some of them aren't unique.

A list with both common and alternative 3-character codes for each municipality where applicable: ### Aveiro District - Águeda: AGD, AGU - Albergaria-a-Velha: ALV, ALB - Anadia: AND, ANA - Arouca: ARO - Aveiro: AVE - Espinho: ESP - Estarreja: EST - Ílhavo: ILH - Mealhada: MEA - Murtosa: MUR - Oliveira de Azeméis: OAZ, OLA - Oliveira do Bairro: OBI - Ovar: OVA - Santa Maria da Feira: SMF - São João da Madeira: SJM - Sever do Vouga: SEV - Vagos: VAG - Vale de Cambra: VDC ### Beja District - Aljustrel: ALJ - Almodôvar: ALM - Alvito: ALV - Barrancos: BAR - Beja: BEJ - Castro Verde: CSV - Cuba: CUB - Ferreira do Alentejo: FDA - Mértola: MER - Moura: MOU - Odemira: ODE - Ourique: OUR - Serpa: SER - Vidigueira: VID ### Braga District - Amares: AMA - Barcelos: BAR - Braga: BRA - Cabeceiras de Basto: CEB - Celorico de Basto: CEL - Esposende: ESP - Fafe: FAF - Guimarães: GUI - Póvoa de Lanhoso: PVL - Terras de Bouro: TDB - Vieira do Minho: VDM - Vila Nova de Famalicão: VNF - Vila Verde: VVE - Vizela: VIZ ### Bragança District - Alfândega da Fé: ALF - Bragança: BRA - Carrazeda de Ansiães: CDA - Freixo de Espada à Cinta: FEC - Macedo de Cavaleiros: MDC - Miranda do Douro: MDD - Mirandela: MIR - Mogadouro: MOG - Torre de Moncorvo: TDM - Vila Flor: VFL - Vimioso: VIM - Vinhais: VIN ### Castelo Branco District - Belmonte: BEL - Castelo Branco: CTB - Covilhã: CVB, CVL - Fundão: FND - Idanha-a-Nova: IDA, IDN - Oleiros: OLE - Penamacor: PEN - Proença-a-Nova: PAN - Sertã: SER - Vila de Rei: VDR - Vila Velha de Ródão: VVR ### Coimbra District - Arganil: ARG - Cantanhede: CAN - Coimbra: COI - Condeixa-a-Nova: CDN - Figueira da Foz: FDF - Góis: GOI - Lousã: LOU - Mealhada: MEA - Miranda do Corvo: MCV - Montemor-o-Velho: MOV - Oliveira do Hospital: OHP - Pampilhosa da Serra: PHS - Penacova: PCV - Penela: PEN - Soure: SOU - Tábua: TAB - Vila Nova de Poiares: VNP ### Évora District - Alandroal: ALD - Arraiolos: ARR - Borba: BOR - Estremoz: EST - Évora: EVO - Montemor-o-Novo: MON - Mourão: MOU - Redondo: RED - Reguengos de Monsaraz: RGM - Vendas Novas: VNO - Viana do Alentejo: VDA - Vila Viçosa: VVC ### Faro District - Albufeira: ALB - Alcoutim: ALC - Aljezur: ALJ - Castro Marim: CAM - Faro: FAR - Lagoa: LAG - Lagos: LGS - Loulé: LOU - Monchique: MON - Olhão: OLH - Portimão: POR - São Brás de Alportel: SBA - Silves: SIL - Tavira: TAV - Vila do Bispo: VDB - Vila Real de Santo António: VRSA ### Guarda District - Aguiar da Beira: AGB - Almeida: ALM - Celorico da Beira: CEB - Figueira de Castelo Rodrigo: FCR - Fornos de Algodres: FDA - Gouveia: GOV - Guarda: GUA - Manteigas: MAN - Mêda: MED - Pinhel: PIN - Sabugal: SAB - Seia: SEI - Trancoso: TRA - Vila Nova de Foz Côa: VNF ### Leiria District - Alcobaça: ALC - Alvaiázere: ALV - Ansião: ANS - Batalha: BAT - Bombarral: BOM - Caldas da Rainha: CAL - Castanheira de Pera: CDP - Figueiró dos Vinhos: FDV - Leiria: LEI - Marinha Grande: MGR - Nazaré: NAZ - Óbidos: OBI - Pedrógão Grande: PDG - Peniche: PEN - Pombal: POM - Porto de Mós: PDM ### Lisboa District - Alenquer: ALE - Amadora: AMA - Arruda dos Vinhos: ARV - Azambuja: AZA - Cadaval: CAD - Cascais: CAS - Lisboa: LIS - Loures: LOU - Lourinhã: LOU - Mafra: MAF - Odivelas: ODI - Oeiras: OEI - Sintra: SIN - Sobral de Monte Agraço: SMA - Torres Vedras: TOV - Vila Franca de Xira: VFX ### Portalegre District - Alter do Chão: ADC - Arronches: ARR - Avis: AVS - Campo Maior: CMR - Castelo de Vide: CDV - Crato: CRA - Elvas: ELV - Fronteira: FRN - Gavião: GAV - Marvão: MAR - Monforte: MON - Nisa: NIS - Ponte de Sor: PDS - Portalegre: POR - Sousel: SOU ### Porto District - Amarante: AMA - Baião: BAI - Felgueiras: FEL - Gondomar: GON - Lousada: LOU - Maia: MAI - Marco de Canaveses: MDC - Matosinhos: MAT - Paços de Ferreira: PFR - Paredes: PAR - Penafiel: PEN - Porto: POR - Póvoa de Varzim: PVZ - Santo Tirso: STS - Trofa: TRO - Valongo: VAL - Vila do Conde: VDC - Vila Nova de Gaia: VNG ### Santarém District - Abrantes: ABR - Alcanena: ALN - Almeirim: ALM - Alpiarça: ALP - Benavente: BEN - Cartaxo: CAR - Chamusca: CHA - Constância: CON - Coruche: COR - Entroncamento: ENT - Ferreira do Zêzere: FDZ - Golegã: GOL - Mação: MAC - Ourém: OUE - Rio Maior: RIO - Salvaterra de Magos: SVM - Santarém: SAN - Sardoal: SAR - Tomar: TOM - Torres Novas: TON - Vila Nova da Barquinha: VNB ### Setúbal District - Alcácer do Sal: ACS - Alcochete: ALH - Almada: ALM - Barreiro: BAR - Grândola: GRA - Moita: MOI - Montijo: MTJ - Palmela: PAL - Santiago do Cacém: STC - Seixal: SEI - Sesimbra: SES - Setúbal: SET - Sines: SIN ### Viana do Castelo District - Arcos de Valdevez: ADV - Caminha: CAM - Melgaço: MEL - Monção: MON - Paredes de Coura: PDC - Ponte da Barca: PDB - Ponte de Lima: PDL - Valença: VAL - Viana do Castelo: VCT - Vila Nova de Cerveira: VNC ### Vila Real District - Alijó: ALJ - Boticas: BOT - Chaves: CHA - Mesão Frio: MSF - Mondim de Basto: MDB - Montalegre: MTG - Murça: MUR - Peso da Régua: PDR - Ribeira de Pena: RDP - Sabrosa: SAB - Santa Marta de Penaguião: SMP - Vila Real: VIL

You CSV looks like something we could work with.

I can only suggest adding the parent subdivision column for each entry. We'll eventually need a mapping of subdivisions and their parents.