PiggyPot / businex

Elixir business day calculations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Businex

Hex pm Build Status

Date calculations based on business calendars. Note, only support for BACS calendar currently. This lib takes influence from the Ruby gem business.

Installation

If available in Hex, the package can be installed by adding businex to your list of dependencies in mix.exs:

def deps do
  [
    {:businex, "~> 0.2.0"}
  ]
end

Ensure businex is started before your application:

def application do
  [applications: [:businex]]
end

Usage

Here are some examples of how to use businex.

iex> Businex.Calendar.set_calendar(:bacs) # :bacs is the default.
:ok
iex> date = Timex.parse!("2018-02-01", "{YYYY}-{0M}-{D}")
iex> Businex.Calendar.next_business_day(date)
~N[2018-02-02 00:00:00]
  iex> Businex.Calendar.business_day?(date)
true
iex> Businex.Calendar.add_business_days(date, 2)
~N[2018-02-05 00:00:00]

Tests

mix test

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/businex.

About

Elixir business day calculations


Languages

Language:Elixir 100.0%