View Source Timex.Parse.Duration.Parser behaviour (timex v3.7.9)

This module is responsible for parsing input strings into Duration structs. The actual parsing is delegated to specific parser modules, but this module provides a unified API for all of them.

Link to this section Summary

Functions

Parses the given input using the ISO-8601 duration parser, and either returns a Duration, or raises an error.

Parses the given input using the provided parser module, and either returns a Duration, or raises an error.

Parses the given input using the ISO-8601 duration parser, and returns either an :ok, or :error tuple.

Parses the given input using the provided parser module, and returns either an :ok, or :error tuple.

Link to this section Callbacks

@callback parse(String.t()) :: {:ok, Timex.Duration.t()} | {:error, term()}

Link to this section Functions

@spec parse!(String.t()) :: Timex.Duration.t() | no_return()

Parses the given input using the ISO-8601 duration parser, and either returns a Duration, or raises an error.

@spec parse!(String.t(), module()) :: Timex.Duration.t() | no_return()

Parses the given input using the provided parser module, and either returns a Duration, or raises an error.

@spec parse(String.t()) :: {:ok, Timex.Duration.t()} | {:error, term()}

Parses the given input using the ISO-8601 duration parser, and returns either an :ok, or :error tuple.

@spec parse(String.t(), module()) :: {:ok, Timex.Duration.t()} | {:error, term()}

Parses the given input using the provided parser module, and returns either an :ok, or :error tuple.