WarframeWorldstateDataElixirTools. DateTimeTools
(warframe_worldstate_data_elixir_tools v0.1.0)
Copy Markdown
View Source
Summary
Functions
Returns a tuple with the start and end of the day from an input timestamp. All timestamps are assumed to be UTC.
Returns milliseconds from now to timestamp (timestamp - now).
Positive = future, negative = past.
Returns milliseconds from timestamp to now (now - timestamp).
Positive = past, negative = future.
Returns a tuple with the start of Monday and end of Sunday for the week containing the input timestamp. All timestamps are assumed to be UTC.
Functions
Returns a tuple with the start and end of the day from an input timestamp. All timestamps are assumed to be UTC.
Examples
iex> dt = ~U[2024-01-15 14:30:00Z]
iex> WarframeWorldstateDataElixirTools.DateTimeTools.daily_reset(dt)
{~U[2024-01-15 00:00:00Z], ~U[2024-01-15 23:59:59Z]}
Returns milliseconds from now to timestamp (timestamp - now).
Positive = future, negative = past.
Examples
iex> now = ~U[2024-01-15 12:00:00Z]
iex> ts = ~U[2024-01-15 12:00:05Z]
iex> WarframeWorldstateDataElixirTools.DateTimeTools.from_now(ts, fn -> now end)
5000
iex> now = ~U[2024-01-15 12:00:00Z]
iex> ts = ~U[2024-01-15 11:59:55Z]
iex> WarframeWorldstateDataElixirTools.DateTimeTools.from_now(ts, fn -> now end)
-5000
Returns milliseconds from timestamp to now (now - timestamp).
Positive = past, negative = future.
Examples
iex> now = ~U[2024-01-15 12:00:00Z]
iex> ts = ~U[2024-01-15 11:59:55Z]
iex> WarframeWorldstateDataElixirTools.DateTimeTools.to_now(ts, fn -> now end)
5000
iex> now = ~U[2024-01-15 12:00:00Z]
iex> ts = ~U[2024-01-15 12:00:05Z]
iex> WarframeWorldstateDataElixirTools.DateTimeTools.to_now(ts, fn -> now end)
-5000
Returns a tuple with the start of Monday and end of Sunday for the week containing the input timestamp. All timestamps are assumed to be UTC.
Examples
iex> dt = ~U[2024-01-17 14:30:00Z]
iex> WarframeWorldstateDataElixirTools.DateTimeTools.weekly_reset(dt)
{~U[2024-01-15 00:00:00Z], ~U[2024-01-21 23:59:59Z]}
iex> dt = ~U[2024-01-15 00:00:00Z]
iex> WarframeWorldstateDataElixirTools.DateTimeTools.weekly_reset(dt)
{~U[2024-01-15 00:00:00Z], ~U[2024-01-21 23:59:59Z]}
iex> dt = ~U[2024-01-21 23:59:59Z]
iex> WarframeWorldstateDataElixirTools.DateTimeTools.weekly_reset(dt)
{~U[2024-01-15 00:00:00Z], ~U[2024-01-21 23:59:59Z]}