GoodTimes
Convenience time functions.
Unless explicitly stated, all functions operate on and return an Erlang datetime based on the Coordinated Universal Time (UTC).
Summary↑
a_day_ago() | Returns the UTC date and time a day ago |
a_day_from_now() | Returns the UTC date and time a day from now |
a_minute_ago() | Returns the UTC date and time a minute ago |
a_minute_from_now() | Returns the UTC date and time a minute from now |
a_second_ago() | Returns the UTC date and time a second ago |
a_second_from_now() | Returns the UTC date and time a second from now |
an_hour_ago() | Returns the UTC date and time an hour ago |
an_hour_from_now() | Returns the UTC date and time an hour from now |
days_ago(days) | Returns the UTC date and time the specified days ago |
days_from_now(days) | Returns the UTC date and time the specified days from now |
hours_ago(hours) | Returns the UTC date and time the specified hours ago |
hours_from_now(hours) | Returns the UTC date and time the specified hours from now |
minutes_ago(minutes) | Returns the UTC date and time the specified minutes ago |
minutes_from_now(minutes) | Returns the UTC date and time the specified minutes from now |
now() | Returns the current UTC time as a datetime |
seconds_ago(seconds) | Returns the UTC date and time the specified seconds ago |
seconds_from_now(seconds) | Returns the UTC date and time the specified seconds from now |
Types ↑
year :: integer
month :: pos_integer
day :: pos_integer
hour :: non_neg_integer
minute :: non_neg_integer
second :: non_neg_integer
Functions
Specs:
- a_day_ago :: datetime
Returns the UTC date and time a day ago.
## Examples
iex> a_day_ago
{{2015, 2, 26}, {18, 30, 45}}
Specs:
- a_day_from_now :: datetime
Returns the UTC date and time a day from now.
## Examples
iex> a_day_from_now
{{2015, 2, 28}, {18, 30, 45}}
Specs:
- a_minute_ago :: datetime
Returns the UTC date and time a minute ago.
## Examples
iex> a_minute_ago
{{2015, 2, 27}, {18, 29, 45}}
Specs:
- a_minute_from_now :: datetime
Returns the UTC date and time a minute from now.
## Examples
iex> a_minute_from_now
{{2015, 2, 27}, {18, 31, 45}}
Specs:
- a_second_ago :: datetime
Returns the UTC date and time a second ago.
a_second_ago # => {{2015, 2, 27}, {18, 30, 44}}
Specs:
- a_second_from_now :: datetime
Returns the UTC date and time a second from now.
## Examples
iex> a_second_from_now
{{2015, 2, 27}, {18, 30, 46}}
Specs:
- an_hour_ago :: datetime
Returns the UTC date and time an hour ago.
## Examples
iex> an_hour_ago
{{2015, 2, 27}, {17, 30, 45}}
Specs:
- an_hour_from_now :: datetime
Returns the UTC date and time an hour from now.
## Examples
iex> an_hour_from_now
{{2015, 2, 27}, {19, 30, 45}}
Specs:
- days_ago(integer) :: datetime
Returns the UTC date and time the specified days ago.
Examples
iex> 7 |> days_ago
{{2015, 2, 20}, {18, 30, 45}}
Specs:
- days_from_now(integer) :: datetime
Returns the UTC date and time the specified days from now.
Examples
iex> 2 |> days_from_now
{{2015, 3, 1}, {18, 30, 45}}
Specs:
- hours_ago(integer) :: datetime
Returns the UTC date and time the specified hours ago.
Examples
iex> 2 |> hours_ago
{{2015, 2, 27}, {16, 30, 45}}
Specs:
- hours_from_now(integer) :: datetime
Returns the UTC date and time the specified hours from now.
Examples
iex> 6 |> hours_from_now
{{2015, 2, 28}, {0, 30, 45}}
Specs:
- minutes_ago(integer) :: datetime
Returns the UTC date and time the specified minutes ago.
Examples
iex> 5 |> minutes_ago
{{2015, 2, 27}, {18, 25, 45}}
Specs:
- minutes_from_now(integer) :: datetime
Returns the UTC date and time the specified minutes from now.
Examples
iex> 10 |> minutes_from_now
{{2015, 2, 27}, {18, 40, 45}}
Specs:
- now :: datetime
Returns the current UTC time as a datetime.
Examples
iex> now
{{2015, 2, 27}, {18, 30, 45}}
Specs:
- seconds_ago(integer) :: datetime
Returns the UTC date and time the specified seconds ago.
Examples
iex> 20 |> seconds_ago
{{2015, 2, 27}, {18, 30, 25}}
Specs:
- seconds_from_now(integer) :: datetime
Returns the UTC date and time the specified seconds from now.
Examples
iex> 15 |> seconds_from_now
{{2015, 2, 27}, {18, 31, 0}}