Feel.Builtin.Conversion (feel v0.1.0)

Copy Markdown View Source

The conversion functions of FEEL (DMN 1.6, section 10.3.4.1, Table 73).

They build values of the temporal types, numbers, strings, and ranges from other values, mostly from text: date("2020-01-01"), number("1.000,5", ".", ","), string(x), range("[1..5]"). The temporal constructors read the lexical forms of XML Schema.

What is written

All eight: date, time, date and time, duration, years and months duration and string (D-56), and number and range (D-73).

CallResult
date(from)from is a string (Feel.Value.Date.parse/1), or the date of a date and time as it is written, whatever its zone; a date is a date and time at UTC midnight (D-56), so its date is itself
date(year, month, day)the numbers, with a fraction cut off
time(from)a string (Feel.Value.Time.parse/1), a time, or the time of a date and time with its zone; a date is a date and time at UTC midnight (D-56, the TCK, 1116 #053)
time(hour, minute, second, offset)the offset is a days and time duration in seconds, or null for a time with no zone; it can be left out
date and time(from)a string (Feel.Value.DateTime.parse/1); a date alone is local midnight, and a date and a zone is midnight in the zone ("2012-03-07Z", D-68)
date and time(date, time)the date of a date or a date and time, and the time with its zone
date and time(date, time, timezone)the same for a time with no zone, which gets the zone timezone: "Z", "+01:00" or the id of a zone
duration(from)a string, of either kind
years and months duration(from, to)the whole months between two dates, or dates and times, taken by their dates (see below)
string(from)the text of a value (Feel.Value.Format); null for null
number(from)a number is itself; a string is a number as a literal is (-1.5, .5, 1e3), and nothing else is
number(from, grouping separator, decimal separator)the string, with every grouping separator taken out and a decimal comma made a period (see below)
range(from)the text of an interval, [18..21), with literal endpoints (Feel.Runtime.RangeText)

A null argument is out of the domain of every function here, and the call is null with an :argument_out_of_domain error, but for the offset of time (null is a time with no zone) and for string(null), which is null and no error (the TCK, 1115 to 1121 and 0079). So is an argument of the wrong kind, a string that is not a date, time, date and time or duration, and a number out of range.

number(from, grouping separator, decimal separator) is the procedure of the footnote of Table 73. The grouping separator is a space, a comma, a period or null, the decimal separator is a period, a comma or null, and they differ unless both are null; any other separator, and a from that is not a string, is null with an error. Every grouping separator is taken out of from, a decimal comma is made a period, and what is left has to be a number as a literal is. A decimal separator that is null leaves the period as it is, so number("1,000,000.00", ",", null) is 1000000.00. Where the grouping separators stand is not looked at ("1,0,0,0" is 1000), and the scale of the text is kept. The two-argument form does not exist.

The months between two dates are to - from in years and months, less one if to is before from in the month (2013-08-24 to 2017-12-15 is 51). The time of day and the zone of a date and time are not looked at (2014-12-31T23:59:59 to 2016-12-31T00:00:01 is 24, as the TCK has it), and a date can be given for either: the date of a date and time is its fields, as written.

Summary

Functions

The functions of this module that are written, as Feel.Builtin.Functions.

Returns the canonical names of the functions of this module, sorted.

Functions

functions()

@spec functions() :: [Feel.Builtin.Function.t()]

The functions of this module that are written, as Feel.Builtin.Functions.

names()

@spec names() :: [Feel.Name.t()]

Returns the canonical names of the functions of this module, sorted.

iex> "date and time" in Feel.Builtin.Conversion.names()
true