   @impl true
   def day_of_week(year, month, day)
       when is_integer(year) and is_integer(month) and is_integer(day) do
-    :calendar.day_of_the_week(year, month, day)
+    Integer.mod((date_to_iso_days(year, month, day) + 5), 7) + 1
   end
 
   @doc """


  @impl true
  def valid_date?(year, month, day) do
    year <= 9999 and :calendar.valid_date(year, month, day)
  end

  @impl true

  def date_to_iso_days(1970, 1, 1) do
    719528
  end
  def date_to_iso_days(year, month, day) when year in 0..9999 do
    true = day <= days_in_month(year, month)
    days_in_previous_years(year) + days_before_month(month) + leap_day_offset(year, month) + day - 1
  end

  # Converts count of days since 0000-01-01 to {year, month, day} tuple.
  @doc false
  def date_from_iso_days(days) when days in 0..3652424 do
    {year, day_of_year} = days_to_year(days)
    extra_day = if leap_year?(year), do: 1, else: 0
    {month, day_in_month} = year_day_to_year_date(extra_day, day_of_year)
    {year, month, day_in_month + 1}
  end

  defp div_mod(int1, int2) do
