Sml.Time (SmlEx v0.1.0)

Copy Markdown View Source

Decoding of SML_Time.

SML times are a choice of

  • 1 - secIndex, seconds since an arbitrary point (usually power on), decoded as {:sec_index, seconds}
  • 2 - timestamp, Unix time in UTC, decoded as DateTime
  • 3 - localTimestamp, Unix time plus local and daylight saving offsets in minutes, decoded as {:local_timestamp, DateTime, local_offset, season_offset}

Summary

Functions

Decodes a parsed SML_Time term.

Types

t()

@type t() ::
  {:sec_index, non_neg_integer()}
  | DateTime.t()
  | {:local_timestamp, DateTime.t(), integer(), integer()}
  | nil

Functions

decode(seconds)

@spec decode(Sml.Parser.term_t()) :: t() | {:unknown, term()}

Decodes a parsed SML_Time term.

iex> Sml.Time.decode([1, 1234])
{:sec_index, 1234}

iex> Sml.Time.decode([2, 1_700_000_000])
~U[2023-11-14 22:13:20Z]