@@ -1092,7 +1092,8 @@ defmodule DateTime do
10921092 @ spec to_iso8601 ( Calendar . datetime ( ) , :basic | :extended , nil | integer ( ) ) :: String . t ( )
10931093 def to_iso8601 ( datetime , format \\ :extended , offset \\ nil )
10941094
1095- def to_iso8601 ( % { calendar: Calendar.ISO } = datetime , format , offset ) do
1095+ def to_iso8601 ( % { calendar: Calendar.ISO } = datetime , format , offset )
1096+ when format in [ :extended , :basic ] do
10961097 datetime
10971098 |> to_iso8601_iodata ( format , offset )
10981099 |> IO . iodata_to_binary ( )
@@ -1105,8 +1106,7 @@ defmodule DateTime do
11051106 |> to_iso8601 ( format , offset )
11061107 end
11071108
1108- defp to_iso8601_iodata ( datetime , format , nil )
1109- when format in [ :extended , :basic ] do
1109+ defp to_iso8601_iodata ( datetime , format , nil ) do
11101110 % {
11111111 year: year ,
11121112 month: month ,
@@ -1130,8 +1130,7 @@ defmodule DateTime do
11301130 % { microsecond: { _ , precision } , time_zone: "Etc/UTC" } = datetime ,
11311131 format ,
11321132 0
1133- )
1134- when format in [ :extended , :basic ] do
1133+ ) do
11351134 { year , month , day , hour , minute , second , { microsecond , _ } } = shift_by_offset ( datetime , 0 )
11361135
11371136 [
@@ -1149,8 +1148,7 @@ defmodule DateTime do
11491148 ]
11501149 end
11511150
1152- defp to_iso8601_iodata ( datetime , format , offset )
1153- when format in [ :extended , :basic ] do
1151+ defp to_iso8601_iodata ( datetime , format , offset ) do
11541152 { _ , precision } = datetime . microsecond
11551153 { year , month , day , hour , minute , second , { microsecond , _ } } = shift_by_offset ( datetime , offset )
11561154
0 commit comments