Date.day_of_week
You're seeing just the function
day_of_week
, go back to Date module for more information.
Specs
day_of_week(Calendar.date(), starting_on :: :default | atom()) :: Calendar.day_of_week()
Calculates the day of the week of a given date
.
Returns the day of the week as an integer. For the ISO 8601 calendar (the default), it is an integer from 1 to 7, where 1 is Monday and 7 is Sunday.
An optional starting_on
value may be supplied, which
configures the weekday the week starts on. The default value
for it is :default
, which translates to :monday
for the
built-in ISO calendar. Any other weekday may be given to.
Examples
iex> Date.day_of_week(~D[2016-10-31])
1
iex> Date.day_of_week(~D[2016-11-01])
2
iex> Date.day_of_week(~N[2016-11-01 01:23:45])
2
iex> Date.day_of_week(~D[-0015-10-30])
3
iex> Date.day_of_week(~D[2016-10-31], :sunday)
2
iex> Date.day_of_week(~D[2016-11-01], :sunday)
3
iex> Date.day_of_week(~N[2016-11-01 01:23:45], :sunday)
3
iex> Date.day_of_week(~D[-0015-10-30], :sunday)
4