The FEEL type years and months duration (DMN 1.6, section 10.3.2.3.8).
A whole number of months, positive or negative. A month has no fixed length in
seconds, so this type never mixes with days and time duration: the two have
no common supertype and are not comparable, except that zero-length durations
of both kinds are equal in one section of the specification.
The components FEEL exposes (years, and months from 0 to 11) are computed
from the total when read; they are not stored.
Fields
:months- the total number of months, an integer.
Summary
Functions
Builds a duration from a total number of months.
Parses a duration string of years and months, as duration("...") and @"..." read
it: the lexical space of the XPath yearMonthDuration (DMN 1.6, section 10.3.4.1).
Returns the type descriptor of years and months duration.
Returns true for a t/0 with an integer number of months.
Types
@type t() :: %Feel.Value.YearsAndMonthsDuration{months: integer()}
Functions
Builds a duration from a total number of months.
iex> Feel.Value.YearsAndMonthsDuration.new(13)
%Feel.Value.YearsAndMonthsDuration{months: 13}
Parses a duration string of years and months, as duration("...") and @"..." read
it: the lexical space of the XPath yearMonthDuration (DMN 1.6, section 10.3.4.1).
It is P, then years (nY), months (nM), or both, in that order, with a leading
- for a negative duration. The months are not limited to 11: P26M is P2Y2M.
White space around the string is ignored. Returns :error for anything else, which
includes a string with days or a time part (P1Y2DT3H: that is not a years and months
duration), a bare P, and a number of months beyond 34 digits.
iex> Feel.Value.YearsAndMonthsDuration.parse("P1Y8M")
{:ok, %Feel.Value.YearsAndMonthsDuration{months: 20}}
iex> Feel.Value.YearsAndMonthsDuration.parse("P26M")
{:ok, %Feel.Value.YearsAndMonthsDuration{months: 26}}
iex> Feel.Value.YearsAndMonthsDuration.parse("-P1Y")
{:ok, %Feel.Value.YearsAndMonthsDuration{months: -12}}
iex> Feel.Value.YearsAndMonthsDuration.parse("P1D")
:error
iex> Feel.Value.YearsAndMonthsDuration.parse("P")
:error
@spec type() :: Feel.Type.t()
Returns the type descriptor of years and months duration.
Returns true for a t/0 with an integer number of months.