Date.beginning_of_week

You're seeing just the function beginning_of_week, go back to Date module for more information.
Link to this function

beginning_of_week(date, starting_on \\ :default)

View Source (since 1.11.0)

Specs

beginning_of_week(Calendar.date(), starting_on :: :default | atom()) :: t()

Calculates a date that is the first day of the week for the given date.

If the day is already the first day of the week, it returns the day itself. For the built-in ISO calendar, the week starts on Monday. A weekday rather than :default can be given as starting_on.

Examples

iex> Date.beginning_of_week(~D[2020-07-11])
~D[2020-07-06]
iex> Date.beginning_of_week(~D[2020-07-06])
~D[2020-07-06]
iex> Date.beginning_of_week(~D[2020-07-11], :sunday)
~D[2020-07-05]
iex> Date.beginning_of_week(~D[2020-07-11], :saturday)
~D[2020-07-11]
iex> Date.beginning_of_week(~N[2020-07-11 01:23:45])
~D[2020-07-06]