GoodTimes v1.1.1 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}}
Summary
Functions
Returns the UTC date and time at the start of the given datetime’s day
Returns the UTC date and time at the start of the given datetime’s hour
Returns the UTC date and time at the start of the given datetime’s minute
Returns the UTC date and time at the start of the given datetime’s month
Returns the UTC date and time at the start of the given datetime’s week
Returns the UTC date and time at the start of the given datetime’s year
Returns the UTC date and time at the end of the given datetime’s day
Returns the UTC date and time at the end of the given datetime’s hour
Returns the UTC date and time at the end of the given datetime’s minute
Returns the UTC date and time at the end of the given datetime’s month
Returns the UTC date and time at the end of the given datetime’s week
Returns the UTC date and time at the end of the given datetime’s year
Functions
Specs
beginning_of_day(GoodTimes.datetime) :: GoodTimes.datetime
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}}
Specs
beginning_of_hour(GoodTimes.datetime) :: GoodTimes.datetime
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}}
Specs
beginning_of_minute(GoodTimes.datetime) :: GoodTimes.datetime
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}}
Specs
beginning_of_month(GoodTimes.datetime) :: GoodTimes.datetime
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}}
Specs
beginning_of_week(GoodTimes.datetime) :: GoodTimes.datetime
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}}
Specs
beginning_of_year(GoodTimes.datetime) :: GoodTimes.datetime
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}}
Specs
end_of_day(GoodTimes.datetime) :: GoodTimes.datetime
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}}
Specs
end_of_hour(GoodTimes.datetime) :: GoodTimes.datetime
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}}
Specs
end_of_minute(GoodTimes.datetime) :: GoodTimes.datetime
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}}
Specs
end_of_month(GoodTimes.datetime) :: GoodTimes.datetime
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}}
Specs
end_of_week(GoodTimes.datetime) :: GoodTimes.datetime
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}}
Specs
end_of_year(GoodTimes.datetime) :: GoodTimes.datetime
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}}