Chronix.Evaluator (Chronix v0.2.0)

Copy Markdown View Source

Resolves a Chronix AST (produced by Chronix.Grammar.expression/1) into a DateTime against a reference date.

Callers typically go through Chronix.Parser.parse_expression/2, which handles string normalization and the " at " composition before invoking resolve/2.

Error contract

On failure this module returns {:error, reason} where reason is one of:

  • a binary — a fully-formatted user-facing error message
  • :invalid_date — sentinel indicating the evaluator parsed valid integers but the combination isn't a real calendar date; the façade wraps this with the original input string

See the module docs on Chronix.Grammar for the AST node shapes this module dispatches on.

Summary

Types

opts()

@type opts() :: keyword()

result()

@type result() :: {:ok, DateTime.t()} | {:error, term()}

Functions

resolve(ast, opts \\ [])

@spec resolve(term(), opts()) :: result()