Exampple.Xmpp.Timestamp (exampple v0.10.6)

Module to help us to format correctly the date-times. Most of the times the date-time should appears in ISO-8601 format with a timezone or in UTC. These helpers add the timestamp removing the microseconds and milliseconds and adding even letting us to add some seconds to the specific time.

Link to this section Summary

Functions

This function let us to show the datetime in ISO-8601 format and as second parameter we add a diff which adds that amount of seconds to the datetime.

This function let us to show the naive datetime in UTC format.

Link to this section Functions

Link to this function

to_string(datetime, diff)

This function let us to show the datetime in ISO-8601 format and as second parameter we add a diff which adds that amount of seconds to the datetime.

Examples:

iex> {:ok, ts, 0} = DateTime.from_iso8601("2020-04-30T12:00:00Z")
iex> Exampple.Xmpp.Timestamp.to_string(ts, 3_600)
"2020-04-30T13:00:00Z"
Link to this function

to_utc_string(naive)

This function let us to show the naive datetime in UTC format.

Examples:

iex> {:ok, ts, 0} = DateTime.from_iso8601("2020-04-30T12:00:00Z")
iex> Exampple.Xmpp.Timestamp.to_utc_string(ts)
"2020-04-30T12:00:00Z"