gigasecond
This commit is contained in:
17
elixir/gigasecond/lib/gigasecond.ex
Normal file
17
elixir/gigasecond/lib/gigasecond.ex
Normal file
@@ -0,0 +1,17 @@
|
||||
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
|
||||
Reference in New Issue
Block a user