@@ -852,7 +852,7 @@ defmodule Date do
852
852
end
853
853
854
854
@ doc """
855
- Calculates the day of the week of a given `date`.
855
+ Calculates the ordinal day of the week of a given `date`.
856
856
857
857
Returns the day of the week as an integer. For the ISO 8601
858
858
calendar (the default), it is an integer from 1 to 7, where
@@ -861,10 +861,19 @@ defmodule Date do
861
861
An optional `starting_on` value may be supplied, which
862
862
configures the weekday the week starts on. The default value
863
863
for it is `:default`, which translates to `:monday` for the
864
- built-in ISO calendar. Any other weekday may be given to.
864
+ built-in ISO 8601 calendar. Any other weekday may be used for
865
+ `starting_on`, in such cases, that weekday will be considered the first
866
+ day of the week, and therefore it will be assigned the ordinal number 1.
867
+
868
+ The other calendars, the value returned is an ordinal day of week.
869
+ For example, `1` may mean "first day of the week" and `7` is
870
+ defined to mean "seventh day of the week". Custom calendars may
871
+ also accept their own variations of the `starting_on` parameter
872
+ with their own meaning.
865
873
866
874
## Examples
867
875
876
+ # 2016-10-31 is a Monday and by default Monday is the first day of the week
868
877
iex> Date.day_of_week(~D[2016-10-31])
869
878
1
870
879
iex> Date.day_of_week(~D[2016-11-01])
@@ -874,6 +883,7 @@ defmodule Date do
874
883
iex> Date.day_of_week(~D[-0015-10-30])
875
884
3
876
885
886
+ # 2016-10-31 is a Monday but, as we start the week on Sunday, now it returns 2
877
887
iex> Date.day_of_week(~D[2016-10-31], :sunday)
878
888
2
879
889
iex> Date.day_of_week(~D[2016-11-01], :sunday)
0 commit comments