# `IEC60870.Types.CPTime.CP56Time2a`
[🔗](https://github.com/Ultraluv/ex_iec60870/blob/main/lib/iec60870/types/cp_time.ex#L170)

7-byte binary time (`CP56Time2a`) according to IEC 60870-5-101 7.2.6.18.
Matches `CP56Time2a_*` functions in `cpXXtime2a.c`.

# `t`

```elixir
@type t() :: %IEC60870.Types.CPTime.CP56Time2a{
  day_of_month: 1..31,
  day_of_week: 0..7,
  hour: 0..23,
  invalid: boolean(),
  millisecond: 0..999,
  minute: 0..59,
  month: 1..12,
  second: 0..59,
  substituted: boolean(),
  summer_time: boolean(),
  year: 0..99
}
```

# `decode`

```elixir
@spec decode(binary()) :: {:ok, t(), binary()} | {:error, :insufficient_data}
```

# `encode`

```elixir
@spec encode(t()) :: &lt;&lt;_::56&gt;&gt;
```

# `from_datetime`

```elixir
@spec from_datetime(DateTime.t()) :: t()
```

# `from_ms`

```elixir
@spec from_ms(non_neg_integer()) :: t()
```

# `from_ms_timestamp`

```elixir
@spec from_ms_timestamp(non_neg_integer()) :: t()
```

# `new`

```elixir
@spec new(keyword()) :: t()
```

# `to_ms`

```elixir
@spec to_ms(t()) :: non_neg_integer()
```

# `to_ms_timestamp`

```elixir
@spec to_ms_timestamp(t()) :: non_neg_integer()
```

Converts `CP56Time2a` to Unix epoch milliseconds (UTC), matching `CP56Time2a_toMsTimestamp` in `cpXXtime2a.c`
(where 2-digit `year` is interpreted as `2000 + year`).
Returns `0` if any field is out of valid calendar range.

---

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