Feel.Value.Date (feel v0.1.0)

Copy Markdown View Source

The FEEL type date (DMN 1.6, section 10.3.2.3.5).

A date is a year, month, and day in the proleptic Gregorian calendar, with a year from -999,999,999 to 999,999,999. It has no time of day and no time zone. It is represented as an Elixir Date in the ISO calendar, which covers the whole FEEL year range.

A date does not conform to date and time, although it converts to one at midnight UTC where an implicit conversion applies.

Summary

Functions

Builds a date.

Parses a date string, as date("...") and @"..." read it: YYYY-MM-DD, the lexical space of the XML Schema date (DMN 1.6, section 10.3.4.1).

Returns the type descriptor of date.

Returns true for an ISO-calendar Date within the FEEL year range.

Types

t()

@type t() :: Date.t()

Functions

new(year, month, day)

@spec new(integer(), integer(), integer()) :: {:ok, t()} | :error

Builds a date.

Returns :error when the combination of year, month, and day is not a date, or the year is outside the FEEL range.

iex> Feel.Value.Date.new(2026, 10, 12)
{:ok, ~D[2026-10-12]}
iex> Feel.Value.Date.new(2026, 2, 30)
:error
iex> Feel.Value.Date.new(1_000_000_000, 1, 1)
:error

parse(text)

@spec parse(String.t()) :: {:ok, t()} | :error

Parses a date string, as date("...") and @"..." read it: YYYY-MM-DD, the lexical space of the XML Schema date (DMN 1.6, section 10.3.4.1).

The year has at least four digits and may be negative. White space around the string is ignored. The zone that XML Schema allows after the day (Z, +01:00) is accepted and dropped, since a date has none (notes 06, AE-4, D-54). Returns :error for anything else, including a day that the month does not have.

iex> Feel.Value.Date.parse("2026-10-12")
{:ok, ~D[2026-10-12]}
iex> Feel.Value.Date.parse(" -0044-03-15 ")
{:ok, Date.new!(-44, 3, 15)}
iex> Feel.Value.Date.parse("2012-12-25+01:00")
{:ok, ~D[2012-12-25]}
iex> Feel.Value.Date.parse("2011-02-30")
:error
iex> Feel.Value.Date.parse("2012-12-25T10:00:00")
:error

type()

@spec type() :: Feel.Type.t()

Returns the type descriptor of date.

value?(arg1)

@spec value?(term()) :: boolean()

Returns true for an ISO-calendar Date within the FEEL year range.

iex> Feel.Value.Date.value?(~D[2026-10-12])
true
iex> Feel.Value.Date.value?(~N[2026-10-12 00:00:00])
false