       {:ok, %Date{calendar: Calendar.Holocene, year: 12000, month: 1, day: 1}}
 
   """
-  @spec convert(Calendar.date, Calendar.calendar) :: {:ok, t} | {:error, :incompatible_calendars}
+  @spec convert(Calendar.date(), Calendar.calendar()) ::
+          {:ok, t} | {:error, :incompatible_calendars}
   def convert(%{calendar: calendar, year: year, month: month, day: day}, calendar) do
     {:ok, %Date{calendar: calendar, year: year, month: month, day: day}}
   end
+
   def convert(%{calendar: calendar} = date, target_calendar) do
     if Calendar.compatible_calendars?(calendar, target_calendar) do
       result_date =
         date
         |> to_iso_days()
         |> from_iso_days(target_calendar)
+
       {:ok, result_date}
     else
       {:error, :incompatible_calendars}

      "2000-02-28"

  """
  @spec to_iso8601(Calendar.date, :extended | :basic) :: String.t
  def to_iso8601(date, format \\ :extended) when format in [:basic, :extended] do
    %{year: year, month: month, day: day} = convert!(date, Calendar.ISO)
    Calendar.ISO.date_to_iso8601(year, month, day, format)

      %Date{calendar: Calendar.Holocene, year: 12000, month: 1, day: 1}

  """
  @spec convert!(Calendar.date(), Calendar.calendar()) :: t
  def convert!(date, calendar) do
    case convert(date, calendar) do
      {:ok, value} ->
        value

      {:error, reason} ->
        raise ArgumentError,
              "cannot convert #{inspect(date)} to target calendar #{inspect(calendar)}, reason: #{
                inspect(reason)
              }"
    end
  end

