Chronix.Time (Chronix v0.2.0)

Copy Markdown View Source

Parses time-of-day expressions into Time structs.

Supported forms:

  • "noon" → 12:00:00
  • "midnight" → 00:00:00
  • Meridiem: "3pm", "3 pm", "3 p.m.", "3:15pm", "3:15:30pm"
  • 24-hour: "15:30", "15:30:45"

Summary

Functions

Converts a raw time AST node (produced by Chronix.Grammar.time/1) into a Time struct.

Types

result()

@type result() :: {:ok, Time.t()} | {:error, String.t()}

Functions

from_ast(arg1)

@spec from_ast(term()) :: {:ok, Time.t()} | {:error, :invalid_time}

Converts a raw time AST node (produced by Chronix.Grammar.time/1) into a Time struct.

Returns {:ok, %Time{}} on success or {:error, :invalid_time} when the parsed components are out of range. Callers that need a specific error message should wrap this themselves.

parse(str)

@spec parse(String.t()) :: result()