Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/elixir/lib/calendar/date.ex
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ defmodule Date do
def to_iso8601(%{calendar: _} = date, format) when format in [:basic, :extended] do
date
|> convert!(Calendar.ISO)
|> to_iso8601()
|> to_iso8601(format)
end

@doc """
Expand Down
10 changes: 10 additions & 0 deletions lib/elixir/test/elixir/calendar/date_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ defmodule DateTest do
end
end

test "to_iso8601/2" do
date = ~D[2000-01-01]
assert Date.to_iso8601(date) == "2000-01-01"
assert Date.to_iso8601(date, :basic) == "20000101"

holo_date = Calendar.Holocene.date(12001, 1, 1)
assert Date.to_iso8601(holo_date) == "2001-01-01"
assert Date.to_iso8601(holo_date, :basic) == "20010101"
end

test "to_string/1" do
date = ~D[2000-01-01]
assert to_string(date) == "2000-01-01"
Expand Down
Loading