Holidays (Holidays v0.4.0)

View Source

Provides the on function that gives a list of holidays for a date within specified regions.

The on function accepts either an Elixir Date struct or an Erlang style {year, month, day} tuple.

Note: the :holidays application must be started before use. This can be done by adding :holidays to the list of applications in your mix.exs file:

def application do
  [
    extra_applications: [:logger, :holidays]
  ]
end

Summary

Functions

Wrapper for Holidays.DateCalculator.Easter.gregorian_easter_for(year) so Definition modules don't all need their own copy.

Returns a list of holidays on the given date for the specified regions.

Callback implementation for Application.start/2.

Types

region()

@type region() :: atom()

week()

@type week() :: :first | :second | :third | :fourth | :last

weekday()

@type weekday() ::
  :monday | :tuesday | :wednesday | :thursday | :friday | :saturday | :sunday

Functions

easter(year)

Wrapper for Holidays.DateCalculator.Easter.gregorian_easter_for(year) so Definition modules don't all need their own copy.

For eample, in Holidays.Definitions.Us, Easter Sunday is defined like this:

holiday "Easter Sunday",
  %{regions: [:us],
    function: {Holidays, :easter, [:year]},
    type: :informal}

on(date, regions)

@spec on(Calendar.date() | :calendar.date(), [region()]) :: list()

Returns a list of holidays on the given date for the specified regions.

Accepts either an Elixir Date struct or an Erlang style {year, month, day} tuple.

Examples

iex> Holidays.on(~D[2016-01-01], [:us])
[%{name: "New Year's Day"}]

iex> Holidays.on({2016, 1, 1}, [:us])
[%{name: "New Year's Day"}]

start(type, args)

Callback implementation for Application.start/2.