GothenburgBitFactory / holidata

Holidata is the core of holidata.net, a no-nonsense, ad-free provider of international holiday data.
https://holidata.net
MIT License
47 stars 13 forks source link

Add locale for pt-BR #74

Closed adrianocorrea closed 3 years ago

lauft commented 3 years ago

Hi @adrianocorrea! Thanks for your contribution and sorry for my late answer. I am currently reviewing your changes (all in all it seems you did a thorough job 👍🏻) and merging them with the data set on holidata.net. I hope you are still available for questions, if they arise.

adrianocorrea commented 3 years ago

Hi @lauft, First of all, thank you for the outstanding job you guys are doing with Taskwarrior, Timewarrior, and Holidata; these are terrific projects that help many people daily. Also, thank you for the feedback; it is good to hear that this small contribution might help the project. Feel free to send me any questions you might have, and I will do my best to answer them.

lauft commented 3 years ago

Hi @adrianocorrea!

There are two main questions:

How are those celebrated in Brazil? The municipal level is not reflected in holidata (which would also be quite a task with 5,570 of them), but if the majority of the municipalities holds them I would add them to the list – despite of 'missing' national/federal laws.

For the religious holidays I found Lei n.º 9.093, de 12 de setembro de 1995 which allows up to 4 religious holidays for municipality, but I guess there is no nation or state wide rule.

adrianocorrea commented 3 years ago

Hi @lauft ,

There are 3 holidays on April 21. "Tiradentes" is a national holiday and celebrates the martir of the Minas Gerais Conspiracy, Joaquim José da Silva Xavier. "Execução de Tiradentes" - while also relating to Tiradentes - celebrates his punishment by death (i.e. execution), and is only celebrated in one state, Minas Gerais (MG). Maybe these 2 events can be merged without side effects. The last one, "Fundação de Brasília", coincides in date, but does not relate to "Tiradentes"; it refers to the date when Brasilia - the federal capital of Brazil - was founded and is only celebrated in the Distrito Federal ("DF").

Carnival is "ponto facultativo", which means that it is not a national holiday and it is up to each company to determine if they will or will not grant the day off to their employees. It normally lasts 2-3 days; Tuesday (which is in fact "Carnaval"), the preceding Monday (in some municipalities) and the Wednesday morning (Wednesday, in this case, is called "Quarta-feira de Cinzas" (i.e. "Ash Wednesday"), not Carnaval). The only state where Carnaval is an official holiday is Rio de Janeiro (where the Tuesday of Carnival is a holiday under state law 5,243/2008, but not the other 2 days). However, this is currently being challenged by the Supreme Federal Court as unconstitutional. In case you believe it would be useful to add Carnival as a holiday, it occurs 47 days before Easter. As Carnival lands on a Tuesday, we might need something similar for Monday and for "Quarta-feira de Cinzas" as well.

"Corpus Christi" is also "ponto facultativo" and is only a holiday in some municipalities.

The "Good Friday" (which is called "Sexta-feira Santa" in Brazil) is not a national holiday or "ponto facultativo"; it is only a holiday in some municipalities.

Easter is also not a holiday; it is just a celebratory date.

I hope this helps!

lauft commented 3 years ago

Thanks for the update @adrianocorrea!

If the holidays are exclusive, i.e. DF only celebrates "Fundação de Brasília", MG only "Execução de Tiradentes", and the rest 'just' "Tiradentes", then I would add them as

04-21: [DF] [F] Fundação de Brasília
04-21: [MG] [F] Execução de Tiradentes
04-21: [AC, AL, AP, AM, BA, CE, ES, GO, MA, MT, MS, PA, PB, PR, PE, PI, RJ, RN, RS, RO, RR, SC, SP, SE, TO] [F] Tiradentes

For the rest, I would propose to add "Carnaval" as a "marker holiday" (one might add "ponto facultativo" as a note, but this would require a dedicated function instead of the simple syntax), and the same with Easter (as a sunday it is quite close to a holiday, I guess...).

I think the calculation of "Carnaval" is simply 47 days before Easter (see e.g. https://pt.wikipedia.org/wiki/Carnaval#C%C3%A1lculo) so we can simply add

47 days before Easter: [RVN] Carnaval
Easter: [RVN] Páscoa

at the end of the list.

adrianocorrea commented 3 years ago

Hi @lauft,

I have updated the code to include Easter and Carnaval, as requested.

For "Tiradentes" , "Execução de Tiradentes", and "Fundação de Brasília", note that "Tiradentes" is a national holiday; it is celebrated by all states. "Execução de Tiradentes" is only celebrated in MG (i.e. MG celebrates both). "Fundação de Brasília" is celebrated only in DF (i.e. DF celebrates "Fundação de Brasília" and "Tiradentes"). If these regional holidays are causing conflicts, it is easier to remove the local holidays, since the dates will overlap. I have also adjusted the code for you.

I hope it helps.

lauft commented 3 years ago

Those holidays do not cause conflicts, I was only surprised to find such a situation where two holidays are celebrated at once. Until now, I thought holidays were mutually exclusive... 😅

If MG and DF celebrate both their double holidays, then holidata should reflect this IMHO.

adrianocorrea commented 3 years ago

It is unusual, for sure - but it makes sense when you have two historical events that happened on the same day. Since it does not cause conflicts, I have reverted the commit. This way, if any state decides to revoke their holiday, they still benefit from the national one and vice-versa.

lauft commented 3 years ago

@adrianocorrea Looks good this way, I think we are ready to merge. 🤗

lauft commented 3 years ago

@adrianocorrea I have merged your commits locally (adding a fix to the order of the holiday flags) and pushed them (therefore closing this PR). Again, many thanks for your contribution!

Feel free to report on any changes to the locale, any help is highly appreciated. 🤗