Predicator.Functions.DateFunctions (predicator v3.5.0)

View Source

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 datetime
  • month(date) - Extracts the month from a date or datetime
  • day(date) - Extracts the day from a date or datetime
  • now() - 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

function_result()

@type function_result() :: {:ok, Predicator.Types.value()} | {:error, binary()}

Functions

all_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

call_date_now(arg1, context)

call_day(arg1, context)

call_month(arg1, context)

call_year(arg1, context)