Month.Range (Month v2.2.0)

Copy Markdown View Source

Represents a range of months.

iex> range = Month.Range.new(~M[2019-01], ~M[2019-03])
{:ok, #Month.Range<~M[2019-01], ~M[2019-03]>}
iex> range.months
[~M[2019-01], ~M[2019-02], ~M[2019-03]]

The months field contains all months within the range, inclusive.

Summary

Functions

Creates a new Month.Range using given Months as a start and an end.

Sames as new/2 but returs either result or raises an exception.

Types

t()

@type t() :: %Month.Range{end: Month.t(), months: [Month.t()], start: Month.t()}

Functions

new(first, last)

@spec new(Date.t(), Date.t()) :: {:ok, t()} | {:error, String.t()}
@spec new(Month.t(), Month.t()) :: {:ok, t()} | {:error, String.t()}

Creates a new Month.Range using given Months as a start and an end.

Examples

iex> Month.Range.new(~M[2019-01], ~M[2019-03])
{:ok, #Month.Range<~M[2019-01], ~M[2019-03]>}

new!(first, last)

@spec new!(Date.t(), Date.t()) :: t()
@spec new!(Month.t(), Month.t()) :: t()

Sames as new/2 but returs either result or raises an exception.