18 lines
567 B
Elixir
18 lines
567 B
Elixir
|
defmodule Gigasecond do
|
||
|
@gigasecond 1_000_000_000
|
||
|
|
||
|
@doc """
|
||
|
Calculate a date one billion seconds after an input date.
|
||
|
"""
|
||
|
@spec from({{pos_integer, pos_integer, pos_integer}, {pos_integer, pos_integer, pos_integer}}) ::
|
||
|
{{pos_integer, pos_integer, pos_integer}, {pos_integer, pos_integer, pos_integer}}
|
||
|
def from({{_year, _month, _day}, {_hours, _minutes, _seconds}} = erl_date_time) do
|
||
|
{:ok, from} =
|
||
|
NaiveDateTime.from_erl(erl_date_time)
|
||
|
|
||
|
from
|
||
|
|> NaiveDateTime.add(@gigasecond, :second)
|
||
|
|> NaiveDateTime.to_erl()
|
||
|
end
|
||
|
end
|