# `PgInterop.Interval.ISO8601AlternativeParser`
[🔗](https://github.com/electric-sql/electric/tree/%40core/sync-service%401.6.2/packages/sync-service/lib/pg_interop/interval/iso8601_alternative_parser.ex#L1)

This module parses alternative ISO-8601 duration strings into Interval structs.

# `parse`

```elixir
@spec parse(String.t()) :: {:ok, PgInterop.Interval.t()} | {:error, term()}
```

Parses an ISO-8601 formatted duration string into a Interval struct.
The parse result is wrapped in a :ok/:error tuple.

## Examples

    iex> parse("P0015-3-2T1:14:37.25")
    {:ok, Interval.parse!("P15Y3M2DT1H14M37.25S")}

    iex> parse("P0015-3-2")
    {:ok, Interval.parse!("P15Y3M2D")}

    iex> parse("PT3:12:25.001")
    {:ok, Interval.parse!("PT3H12M25.001S")}

    iex> parse("P0015T30:00")
    {:ok, Interval.parse!("P15YT30H")}

    iex> parse("")
    {:error, "input string cannot be empty"}
    iex> parse("W")
    {:error, "expected P, got W"}
    iex> parse("P0015TT30:00")
    {:error, "unexpected duplicate T"}
    iex> parse("P0015-3-2-1")
    {:error, "unexpected 4th section in y-m-d part"}
    iex> parse("P0015-3-y")
    {:error, "invalid number `y`"}
    iex> parse("P0015-3-1T30:00:10.y")
    {:error, "invalid number `10.y`"}

# `split_on_time`

# `validate_hms`

# `validate_ymd`

---

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