GoodTimes.Boundary

Return the first or last second of a unit of time.

Find the boundaries of a unit of time, i.e. the first/last second of a minute, an hour, day, week, month or year.

Find the first second with beginning_of_<time unit>/1 and the last second with end_of_<time unit>/1. They operate on and return an Erlang datetime based on the Coordinated Universal Time (UTC).

Examples

iex> {{2015, 2, 27}, {18, 30, 45}} |> end_of_month
{{2015, 2, 28}, {23, 59, 59}}
Source

Summary

beginning_of_day(arg1)

Returns the UTC date and time at the start of the given datetime’s day

beginning_of_hour(arg1)

Returns the UTC date and time at the start of the given datetime’s hour

beginning_of_minute(arg1)

Returns the UTC date and time at the start of the given datetime’s minute

beginning_of_month(arg1)

Returns the UTC date and time at the start of the given datetime’s month

beginning_of_week(datetime)

Returns the UTC date and time at the start of the given datetime’s week

beginning_of_year(arg1)

Returns the UTC date and time at the start of the given datetime’s year

end_of_day(arg1)

Returns the UTC date and time at the end of the given datetime’s day

end_of_hour(arg1)

Returns the UTC date and time at the end of the given datetime’s hour

end_of_minute(arg1)

Returns the UTC date and time at the end of the given datetime’s minute

end_of_month(arg1)

Returns the UTC date and time at the end of the given datetime’s month

end_of_week(datetime)

Returns the UTC date and time at the end of the given datetime’s week

end_of_year(arg1)

Returns the UTC date and time at the end of the given datetime’s year

Functions

beginning_of_day(arg1)

Specs:

Returns the UTC date and time at the start of the given datetime’s day.

Examples

iex> {{2015, 2, 27}, {18, 30, 45}} |> beginning_of_day
{{2015, 2, 27}, {0, 0, 0}}
Source
beginning_of_hour(arg1)

Specs:

Returns the UTC date and time at the start of the given datetime’s hour.

Examples

iex> {{2015, 2, 27}, {18, 30, 45}} |> beginning_of_hour
{{2015, 2, 27}, {18, 0, 0}}
Source
beginning_of_minute(arg1)

Specs:

Returns the UTC date and time at the start of the given datetime’s minute.

Examples

iex> {{2015, 2, 27}, {18, 30, 45}} |> beginning_of_minute
{{2015, 2, 27}, {18, 30, 0}}
Source
beginning_of_month(arg1)

Specs:

Returns the UTC date and time at the start of the given datetime’s month.

Examples

iex> {{2015, 2, 27}, {18, 30, 45}} |> beginning_of_month
{{2015, 2, 1}, {0, 0, 0}}
Source
beginning_of_week(datetime)

Specs:

Returns the UTC date and time at the start of the given datetime’s week.

Examples

iex> {{2015, 2, 27}, {18, 30, 45}} |> beginning_of_week
{{2015, 2, 23}, {0, 0, 0}}
Source
beginning_of_year(arg1)

Specs:

Returns the UTC date and time at the start of the given datetime’s year.

Examples

iex> {{2015, 2, 27}, {18, 30, 45}} |> beginning_of_year
{{2015, 1, 1}, {0, 0, 0}}
Source
end_of_day(arg1)

Specs:

Returns the UTC date and time at the end of the given datetime’s day.

Examples

iex> {{2015, 2, 27}, {18, 30, 45}} |> end_of_day
{{2015, 2, 27}, {23, 59, 59}}
Source
end_of_hour(arg1)

Specs:

Returns the UTC date and time at the end of the given datetime’s hour.

Examples

iex> {{2015, 2, 27}, {18, 30, 45}} |> end_of_hour
{{2015, 2, 27}, {18, 59, 59}}
Source
end_of_minute(arg1)

Specs:

Returns the UTC date and time at the end of the given datetime’s minute.

Examples

iex> {{2015, 2, 27}, {18, 30, 45}} |> end_of_minute
{{2015, 2, 27}, {18, 30, 59}}
Source
end_of_month(arg1)

Specs:

Returns the UTC date and time at the end of the given datetime’s month.

Examples

iex> {{2015, 2, 27}, {18, 30, 45}} |> end_of_month
{{2015, 2, 28}, {23, 59, 59}}
Source
end_of_week(datetime)

Specs:

Returns the UTC date and time at the end of the given datetime’s week.

Examples

iex> {{2015, 2, 27}, {18, 30, 45}} |> end_of_week
{{2015, 3, 1}, {23, 59, 59}}
Source
end_of_year(arg1)

Specs:

Returns the UTC date and time at the end of the given datetime’s year.

Examples

iex> {{2015, 2, 27}, {18, 30, 45}} |> end_of_year
{{2015, 12, 31}, {23, 59, 59}}
Source