Tempo.RequiresAnchorError exception (Tempo v0.20.0)

Copy Markdown View Source

Exception returned when arithmetic on an un-anchored value (one with no :year) would depend on the missing year, so it cannot be resolved.

Some un-anchored arithmetic is answerable — ~o"1M31D" shifted by one day is ~o"2M1D", because January always has 31 days. But shifting ~o"1M31D" by one month lands in February, whose length depends on the year, so there is no single answer. In that case Tempo.shift/2 (and the Tempo.Math arithmetic beneath it) returns {:error, %Tempo.RequiresAnchorError{}} rather than guessing or crashing.

Summary

Types

t()

@type t() :: %Tempo.RequiresAnchorError{
  __exception__: term(),
  duration: Tempo.Duration.t() | nil,
  reason: atom() | String.t() | nil,
  value: Tempo.t() | nil
}