Date and time related functions for use in predicator expressions.
This module provides temporal functions for working with dates, times, durations, and relative date calculations.
Available Functions
Date/Time Functions
year(date)- Extracts the year from a date or datetimemonth(date)- Extracts the month from a date or datetimeday(date)- Extracts the day from a date or datetimenow()- Returns the current UTC datetime (alias for Date.now())
Examples
iex> Predicator.Functions.DateFunctions.call_year([~D[2023-05-15]], %{})
{:ok, 2023}
iex> Predicator.Functions.DateFunctions.call_date_now([], %{})
{:ok, %DateTime{}}
Summary
Functions
Returns all date functions as a map in the format expected by the evaluator.
Types
@type function_result() :: {:ok, Predicator.Types.value()} | {:error, binary()}
Functions
@spec all_functions() :: %{required(binary()) => {non_neg_integer(), function()}}
Returns all date functions as a map in the format expected by the evaluator.
Returns
A map where keys are function names and values are {arity, function} tuples.
Examples
iex> functions = Predicator.Functions.DateFunctions.all_functions()
iex> Map.has_key?(functions, "year")
true
iex> {arity, _function} = functions["year"]
iex> arity
1
@spec call_date_now([Predicator.Types.value()], Predicator.Types.context()) :: function_result()
@spec call_day([Predicator.Types.value()], Predicator.Types.context()) :: function_result()
@spec call_month([Predicator.Types.value()], Predicator.Types.context()) :: function_result()
@spec call_year([Predicator.Types.value()], Predicator.Types.context()) :: function_result()