Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev/support/mix/tasks/holidefs.download.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ defmodule Mix.Tasks.Holidefs.Download do

"""

@version "v2.3.0"
@version "v5.7.3"
@endpoint "https://raw.githubusercontent.com/holidays/definitions/#{@version}"
@path Path.join(:code.priv_dir(:holidefs), "/calendars/definitions")

Expand Down
5 changes: 4 additions & 1 deletion lib/holidefs/definition/store.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ defmodule Holidefs.Definition.Store do

alias Holidefs.Definition

definitions = Holidefs.locales() |> Enum.map(fn {c, n} -> Definition.load!(c, n) end) |> Enum.reject(&is_nil/1)
definitions =
Holidefs.locales()
|> Enum.map(fn {c, n} -> Definition.load!(c, n) end)
|> Enum.reject(&is_nil/1)

@doc """
Returns all the loaded definitions with their rules.
Expand Down
4 changes: 4 additions & 0 deletions lib/holidefs/holiday.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ defmodule Holidefs.Holiday do
defp in_year_ranges?(list, year) when is_list(list),
do: Enum.all?(list, &in_year_range?(&1, year))

defp in_year_ranges?(map, year) when is_map(map),
do: in_year_range?(map, year)

defp in_year_range?(%{"before" => before_year}, year), do: year <= before_year
defp in_year_range?(%{"after" => after_year}, year), do: year >= after_year
defp in_year_range?(%{"from" => from_year}, year), do: year >= from_year
defp in_year_range?(%{"limited" => years}, year), do: year in years
defp in_year_range?(%{"between" => years}, year), do: year in years

Expand Down
131 changes: 74 additions & 57 deletions priv/calendars/definitions/br.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,153 +8,170 @@
---
months:
0:
- name: Carnaval # same as Shrove Tuesday
regions: [br]
function: easter(year)
function_modifier: -47
type: informal
- name: Sexta-feira Santa
regions: [br]
function: easter(year)
function_modifier: -2
- name: Páscoa
regions: [br]
function: easter(year)
- name: Corpus Christi
regions: [br]
function: easter(year)
function_modifier: 60
- name: Carnaval # same as Shrove Tuesday
regions: [br]
function: easter(year)
function_modifier: -47
type: informal
- name: Sexta-feira Santa
regions: [br]
function: easter(year)
function_modifier: -2
- name: Páscoa
regions: [br]
function: easter(year)
- name: Corpus Christi
regions: [br]
function: easter(year)
function_modifier: 60
1:
- name: Dia da Confraternização Universal
regions: [br]
mday: 1
- name: Dia da Confraternização Universal
regions: [br]
mday: 1
4:
- name: Dia de Tiradentes
regions: [br]
mday: 21
- name: Dia de Tiradentes
regions: [br]
mday: 21
5:
- name: Dia do Trabalho
regions: [br]
mday: 1
- name: Dia do Trabalho
regions: [br]
mday: 1
9:
- name: Proclamação da Independência
regions: [br]
mday: 7
- name: Proclamação da Independência
regions: [br]
mday: 7
10:
- name: Dia de Nossa Senhora Aparecida
regions: [br]
mday: 12
- name: Dia de Nossa Senhora Aparecida
regions: [br]
mday: 12
11:
- name: Dia de Finados
regions: [br]
mday: 2
- name: Proclamação da República
regions: [br]
mday: 15
- name: Dia de Finados
regions: [br]
mday: 2
- name: Proclamação da República
regions: [br]
mday: 15
- name: Dia Nacional de Zumbi e da Consciência Negra
regions: [br]
mday: 20
year_ranges:
from: 2024
12:
- name: Natal
regions: [br]
mday: 25
- name: Natal
regions: [br]
mday: 25

tests:
- given:
date: '2008-01-01'
date: "2008-01-01"
regions: ["br"]
options: ["informal"]
expect:
name: "Dia da Confraternização Universal"
- given:
date: '2005-02-08'
date: "2005-02-08"
regions: ["br"]
options: ["informal"]
expect:
name: "Carnaval"
- given:
date: '2006-02-28'
date: "2006-02-28"
regions: ["br"]
options: ["informal"]
expect:
name: "Carnaval"
- given:
date: '2007-02-20'
date: "2007-02-20"
regions: ["br"]
options: ["informal"]
expect:
name: "Carnaval"
- given:
date: '2008-02-05'
date: "2008-02-05"
regions: ["br"]
options: ["informal"]
expect:
name: "Carnaval"
- given:
date: '2008-03-21'
date: "2008-03-21"
regions: ["br"]
options: ["informal"]
expect:
name: "Sexta-feira Santa"
- given:
date: '2008-03-23'
date: "2008-03-23"
regions: ["br"]
options: ["informal"]
expect:
name: "Páscoa"
- given:
date: '2008-04-21'
date: "2008-04-21"
regions: ["br"]
options: ["informal"]
expect:
name: "Dia de Tiradentes"
- given:
date: '2008-05-01'
date: "2008-05-01"
regions: ["br"]
options: ["informal"]
expect:
name: "Dia do Trabalho"
- given:
date: '2005-05-26'
date: "2005-05-26"
regions: ["br"]
options: ["informal"]
expect:
name: "Corpus Christi"
- given:
date: '2007-06-07'
date: "2007-06-07"
regions: ["br"]
options: ["informal"]
expect:
name: "Corpus Christi"
- given:
date: '2008-05-22'
date: "2008-05-22"
regions: ["br"]
options: ["informal"]
expect:
name: "Corpus Christi"
- given:
date: '2008-09-07'
date: "2008-09-07"
regions: ["br"]
options: ["informal"]
expect:
name: "Proclamação da Independência"
- given:
date: '2008-10-12'
date: "2008-10-12"
regions: ["br"]
options: ["informal"]
expect:
name: "Dia de Nossa Senhora Aparecida"
- given:
date: '2008-11-02'
date: "2008-11-02"
regions: ["br"]
options: ["informal"]
expect:
name: "Dia de Finados"
- given:
date: '2008-11-15'
date: "2008-11-15"
regions: ["br"]
options: ["informal"]
expect:
name: "Proclamação da República"
- given:
date: '2008-12-25'
date: "2023-11-20"
regions: ["br"]
options: ["informal"]
expect:
holiday: false
- given:
date: "2024-11-20"
regions: ["br"]
options: ["informal"]
expect:
name: "Dia Nacional de Zumbi e da Consciência Negra"
- given:
date: "2008-12-25"
regions: ["br"]
options: ["informal"]
expect:
Expand Down
3 changes: 3 additions & 0 deletions priv/gettext/br.pot
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ msgstr ""
msgid "Proclamação da República"
msgstr ""

msgid "Dia Nacional de Zumbi e da Consciência Negra"
msgstr ""

msgid "Natal"
msgstr ""

Loading