Hi Kip, my concern with this PR is that it opens up the path for "duplicating" several of the functions in the Date module:
Date.iso_beginning_of_month/1 Date.iso_beginning_of_week/2 Date.iso_day_of_era/1 Date.iso_day_of_week/1 Date.iso_day_of_year/1 Date.iso_days_in_month/1 Date.iso_end_of_month/1 Date.iso_end_of_week/2 Date.iso_months_in_year/1 Date.iso_quarter_of_year/1 Date.iso_year_of_era/1 Perhaps not all of the above but at least a few. Also, in your case, couldn't you support a custom starting_on value called :iso_default or :monday, which will behave as you described? So your :default can adhere to your custom calendar semantics, and then either :monday or :iso_default returns what the computation above would provide. *José Valimhttps://dashbit.co/ <https://dashbit.co/>* On Sat, Jan 11, 2025 at 9:45 AM Kip <kipco...@gmail.com> wrote: > A recent discussion <https://github.com/elixir-lang/elixir/pull/14162> > clarified > that the return value from `Date.day_of_week/2` is an ordinal value. That > is, when it returns "1" that means "first day of week". It specifically > does not mean "1" is Monday. > > That means that it would be useful to have a function that does return the > cardinal day of week - that is, a number where 1 == Monday and 7 == Sunday. > > The function would look something like: > > def iso_day_of_week(%{calendar: Calendar.ISO} = date) do > day_of_week(date) > end > > def iso_day_of_week(date) do > date > |> convert!(Calendar.ISO) > |> day_of_week() > end > > This implementation relies on the knowledge that when called with > starting_on = :default (which is the default argument value) the returned > value is indeed 1 == Monday, 7 == Sunday. > > If there is any consensus I'll submit a PR. > > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to elixir-lang-core+unsubscr...@googlegroups.com. > To view this discussion visit > https://groups.google.com/d/msgid/elixir-lang-core/eeff3e35-448b-4dcf-ad4a-866bac76a819n%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/eeff3e35-448b-4dcf-ad4a-866bac76a819n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4K1Avrg-Ro_%3DWdNTtwOM9CV-oWPPbn2rprG%2B5en9XPwOA%40mail.gmail.com.