Timex.Parse.DateTime.Tokenizers.Directive (timex v4.0.0)

Copy Markdown View Source

A parsing directive produced by a datetime tokenizer.

Custom tokenizers and formatters use these directives to describe literal text and date/time fields, including their padding, width and parsing rules.

Summary

Functions

Gets a parsing directive for the given token name, where the token name is an atom.

Types

t()

@type t() :: %Timex.Parse.DateTime.Tokenizers.Directive{
  flags: term(),
  modifiers: term(),
  parser: term(),
  parser_origin: term(),
  type: term(),
  value: term(),
  weight: term(),
  width: term()
}

Functions

get(type, directive, opts \\ [])

@spec get(atom(), String.t(), [{atom(), term()}] | []) :: t()

Gets a parsing directive for the given token name, where the token name is an atom.

Examples

iex> alias Timex.Parse.DateTime.Tokenizers.Directive
...> %Directive{type: type, flags: flags} = Directive.get(:year4, "YYYY", flags: [padding: :zeros])
...> {type, flags[:padding]}
{:year4, :zeros}

get(type, directive, flags, mods, width)