       ~T[23:00:07.0]
 
   """
-  @spec to_time(t) :: Time.t
-  def to_time(%DateTime{hour: hour, minute: minute, second: second, microsecond: microsecond, calendar: calendar}) do
-    %Time{hour: hour, minute: minute, second: second, microsecond: microsecond, calendar: calendar}
+  @spec to_time(t) :: Time.t()
+  def to_time(%DateTime{} = datetime) do
+    %{hour: hour, minute: minute, second: second, microsecond: microsecond, calendar: calendar} =
+      datetime
+
+    %Time{
+      hour: hour,
+      minute: minute,
+      second: second,
+      microsecond: microsecond,
+      calendar: calendar
+    }
   end
 
   @doc """

                      zone_abbr: "AMT"}}

  """
  @spec convert(Calendar.datetime, Calendar.calendar) :: {:ok, t} | {:error, :incompatible_calendars}
  def convert(%{calendar: calendar, year: year, month: month, day: day,
                hour: hour, minute: minute, second: second, microsecond: microsecond,
                time_zone: time_zone, zone_abbr: zone_abbr, utc_offset: utc_offset, std_offset: std_offset}, calendar) do
    {:ok, %DateTime{calendar: calendar, year: year, month: month, day: day,
                    hour: hour, minute: minute, second: second, microsecond: microsecond,
                    time_zone: time_zone, zone_abbr: zone_abbr, utc_offset: utc_offset, std_offset: std_offset}}
  end

  def convert(%{calendar: dt_calendar, microsecond: {_, precision}} = datetime, calendar) do

      {:error, :invalid_format}

  """
  @spec from_iso8601(String.t(), Calendar.calendar()) ::
          {:ok, t, Calendar.utc_offset()} | {:error, atom}
  def from_iso8601(string, calendar \\ Calendar.ISO) when is_binary(string) do
    with <<year::4-bytes, ?-, month::2-bytes, ?-, day::2-bytes, sep, rest::binary>> <- string,
         true <- sep in [?\s, ?T],
         <<hour::2-bytes, ?:, min::2-bytes, ?:, sec::2-bytes, rest::binary>> <- rest,
         {year, ""} <- Integer.parse(year),
         {month, ""} <- Integer.parse(month),
         {day, ""} <- Integer.parse(day),
         {hour, ""} <- Integer.parse(hour),
