IEC60870.Types.CPTime.CP56Time2a (ExIEC60870 v0.1.0)

Copy Markdown View Source

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

Summary

Functions

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.

Types

t()

@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
}

Functions

decode(arg1)

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

encode(t)

@spec encode(t()) :: <<_::56>>

from_datetime(dt)

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

from_ms(timestamp_ms)

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

from_ms_timestamp(timestamp_ms)

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

new(opts \\ [])

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

to_ms(t)

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

to_ms_timestamp(t)

@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.