# `HL7v2.Type.TS`
[🔗](https://github.com/Balneario-de-Cofrentes/hl7v2/blob/v3.10.1/lib/hl7v2/type/ts.ex#L1)

Time Stamp (TS) -- HL7v2 composite data type.

Legacy composite with 2 components: time (DTM format) and degree of precision.
Retained for backward compatibility with v2.4 and earlier. In v2.5+, DTM is
preferred for new fields.

Component 2 (degree of precision) is deprecated. Values from Table 0529:
Y (year), L (month), D (day), H (hour), M (minute), S (second).

# `t`

```elixir
@type t() :: %HL7v2.Type.TS{
  degree_of_precision: binary() | nil,
  time: HL7v2.Type.DTM.t() | nil
}
```

# `encode`

```elixir
@spec encode(t() | nil) :: list()
```

Encodes a timestamp to a list of component strings.

## Examples

    iex> HL7v2.Type.TS.encode(%HL7v2.Type.TS{time: %HL7v2.Type.DTM{year: 2026, month: 3, day: 22}})
    ["20260322"]

    iex> HL7v2.Type.TS.encode(%HL7v2.Type.TS{time: %HL7v2.Type.DTM{year: 2026, month: 3, day: 22}, degree_of_precision: "D"})
    ["20260322", "D"]

    iex> HL7v2.Type.TS.encode(nil)
    []

# `parse`

```elixir
@spec parse(list()) :: t()
```

Parses a timestamp from a list of components.

## Examples

    iex> HL7v2.Type.TS.parse(["20260322143022"])
    %HL7v2.Type.TS{time: %HL7v2.Type.DTM{year: 2026, month: 3, day: 22, hour: 14, minute: 30, second: 22}}

    iex> HL7v2.Type.TS.parse(["20260322", "D"])
    %HL7v2.Type.TS{time: %HL7v2.Type.DTM{year: 2026, month: 3, day: 22}, degree_of_precision: "D"}

    iex> HL7v2.Type.TS.parse([])
    %HL7v2.Type.TS{}

---

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