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

Time (TM) -- HL7v2 primitive data type.

Format: `HH[MM[SS[.S[S[S[S]]]]]][+/-ZZZZ]`

Parses to a `%TM{}` struct preserving all fields for lossless round-trip
encoding. Similar to DTM but without the date portion.

# `t`

```elixir
@type t() :: %HL7v2.Type.TM{
  fraction: binary() | nil,
  hour: non_neg_integer(),
  minute: non_neg_integer() | nil,
  offset: binary() | nil,
  original: term(),
  second: non_neg_integer() | nil
}
```

# `encode`

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

Encodes a TM value back to HL7v2 format.

## Examples

    iex> HL7v2.Type.TM.encode(%HL7v2.Type.TM{hour: 14, minute: 30})
    "1430"

    iex> HL7v2.Type.TM.encode(%HL7v2.Type.TM{hour: 14, minute: 30, second: 22, fraction: "1234", offset: "+0100"})
    "143022.1234+0100"

    iex> HL7v2.Type.TM.encode(nil)
    ""

# `parse`

```elixir
@spec parse(binary() | nil) :: t() | nil
```

Parses a TM string into a `%TM{}` struct.

## Examples

    iex> HL7v2.Type.TM.parse("143022.1234+0100")
    %HL7v2.Type.TM{hour: 14, minute: 30, second: 22, fraction: "1234", offset: "+0100"}

    iex> HL7v2.Type.TM.parse("1430")
    %HL7v2.Type.TM{hour: 14, minute: 30}

    iex> HL7v2.Type.TM.parse("14")
    %HL7v2.Type.TM{hour: 14}

    iex> HL7v2.Type.TM.parse("")
    nil

    iex> HL7v2.Type.TM.parse(nil)
    nil

---

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