# `Ankusa.ULID`
[🔗](https://github.com/jamescarr/ankusa/blob/ankusa-v0.7.0/packages/ankusa/lib/ankusa/ulid.ex#L1)

The ULID text form of 128 bits: 26 characters of Crockford base32
(`0-9`, `A-Z` minus `I`, `L`, `O`, `U`), most significant bits first, so
the first 48 bits (a Unix millisecond timestamp) make the string sort by
time.

Only the canonical, uppercase form is accepted. The ULID spec lets a
decoder fold case and read `I`/`L` as `1` and `O` as `0`; this module
doesn't, so every id has exactly one spelling in a URN, a URL path, and a
storage key.

# `decode`

```elixir
@spec decode(term()) :: {:ok, &lt;&lt;_::128&gt;&gt;} | :error
```

Decode a canonical ULID to its 128 bits. `:error` for anything else,
including a timestamp past what `DateTime` can represent; never raises on
untrusted input.

# `encode`

```elixir
@spec encode(&lt;&lt;_::128&gt;&gt;) :: String.t()
```

Encode 128 bits as a canonical ULID.

# `timestamp_ms`

```elixir
@spec timestamp_ms(&lt;&lt;_::128&gt;&gt;) :: non_neg_integer()
```

The 48-bit Unix millisecond timestamp of 128 ULID bits.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
