# `NumberF.DateCalculations`
[🔗](https://github.com/jamesnjovu/elixir_number_functions/blob/v0.3.0/lib/number_f/date_calculations.ex#L1)

Functions for performing date-based calculations.

# `add_business_days`

Calculates the date after adding a specified number of business days.

# `age_in_months`

Age in whole months.

## Examples

    iex> NumberF.DateCalculations.age_in_months(~D[2020-01-15], ~D[2024-08-22])
    55

# `business_days_between`

Calculates the number of business days between two dates.

# `calculate_age`

Calculates age based on birth date.

# `days_between`

Calculates the number of days between two dates.

# `days_in_month`

Number of days in a given month.

## Examples

    iex> NumberF.DateCalculations.days_in_month(2024, 2)
    29

    iex> NumberF.DateCalculations.days_in_month(2023, 2)
    28

# `fiscal_year`

Fiscal year containing the date, given the month the fiscal year starts in.

The year returned is the one the fiscal year *ends* in, which is the common
convention: with an April start, 2024-08-22 falls in FY2025.

## Examples

    iex> NumberF.DateCalculations.fiscal_year(~D[2024-08-22], 4)
    2025

    iex> NumberF.DateCalculations.fiscal_year(~D[2024-02-10], 4)
    2024

# `is_business_day?`

Determines if a date is a business day.

# `leap_year?`

Whether a year is a leap year in the proleptic Gregorian calendar.

## Examples

    iex> NumberF.DateCalculations.leap_year?(2024)
    true

    iex> NumberF.DateCalculations.leap_year?(1900)
    false

# `month_end`

Last day of the date's month.

## Examples

    iex> NumberF.DateCalculations.month_end(~D[2024-02-10])
    ~D[2024-02-29]

# `month_start`

First day of the date's month.

## Examples

    iex> NumberF.DateCalculations.month_start(~D[2024-08-22])
    ~D[2024-08-01]

# `next_business_day`

Calculates the next business day after the given date.

# `payment_due_date`

Calculates payment due date based on invoice date and terms.

# `quarter`

Calendar quarter of a date, 1 to 4.

## Examples

    iex> NumberF.DateCalculations.quarter(~D[2024-08-22])
    3

# `quarter_end`

Last day of the date's calendar quarter.

## Examples

    iex> NumberF.DateCalculations.quarter_end(~D[2024-08-22])
    ~D[2024-09-30]

# `quarter_start`

First day of the date's calendar quarter.

## Examples

    iex> NumberF.DateCalculations.quarter_start(~D[2024-08-22])
    ~D[2024-07-01]

# `week_number`

ISO-8601 week number.

## Edge cases

ISO weeks belong to the year containing their Thursday, so the first days of
January can fall in week 52 or 53 of the previous year.

## Examples

    iex> NumberF.DateCalculations.week_number(~D[2024-08-22])
    34

---

*Consult [api-reference.md](api-reference.md) for complete listing*
