Tempo.Sigils (Tempo v0.3.0)

Copy Markdown View Source

Sigils for constructing %Tempo{} values at compile time.

Provides ~o (and its verbose alias ~TEMPO) to turn an ISO 8601 / ISO 8601-2 / IXDTF / EDTF string into a %Tempo{}, %Tempo.Interval{}, %Tempo.Duration{}, or %Tempo.Set{} struct.

import Tempo.Sigils

~o"2026-06-15"            #=> %Tempo{…}
~o"2026-06-15T10:30:00Z"  #=> zoned datetime
~o"1984?/2004~"           #=> qualified interval
~o"2026Y"w                #=> ISO week calendar (w modifier)

Why a module just for sigils

The module exposes only the sigil macros so import Tempo.Sigils in application code adds exactly sigil_o/2 and sigil_TEMPO/2 to the caller's scope — no helper functions leak into the caller's namespace. Any expansion-time helpers live in a private sibling module that isn't part of the public API.

Modifiers

  • No modifier — Gregorian calendar (the common case).

  • w — ISO Week calendar (Calendrical.ISOWeek). Use when the input is in a week-based form you want parsed under ISO week semantics explicitly.

Summary

Functions

Parse an ISO 8601 / EDTF / IXDTF string at compile time.

Verbose alias for sigil_o. Use when ~o might be confused with another sigil in scope, or when you want the three-letter form for readability in dense code.

Functions

sigil_o(arg, opts)

(macro)

Parse an ISO 8601 / EDTF / IXDTF string at compile time.

The value is fully resolved to its %Tempo{} / %Tempo.Interval{} / %Tempo.Duration{} / %Tempo.Set{} form by the parser and escaped as a compile-time literal, so there is no runtime parse cost at the call site.

sigil_TEMPO(arg, opts)

(macro)

Verbose alias for sigil_o. Use when ~o might be confused with another sigil in scope, or when you want the three-letter form for readability in dense code.