Skip to content

Commit

Permalink
Allow second precision on CalendarInterval ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
kipcole9 committed Jun 13, 2020
1 parent cfa41f5 commit a347600
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/cldr/interval.ex
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,13 @@ defmodule Cldr.Interval do
to = %{to | second: 0, microsecond: {0, 6}}
Cldr.DateTime.Interval.to_string(from, to, backend, options)
end

def to_string(%CalendarInterval{first: from, last: to, precision: precision}, backend, options)
when precision in [:second, :microsecond] do
from = %{from | microsecond: {0, 6}}
to = %{to | microsecond: {0, 6}}
Cldr.DateTime.Interval.to_string(from, to, backend, options)
end
end

@doc false
Expand Down
4 changes: 2 additions & 2 deletions lib/cldr/interval/date_time.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ defmodule Cldr.DateTime.Interval do
end

def to_string(%CalendarInterval{first: from, last: to, precision: precision}, backend, options)
when precision in [:hour, :minute] do
when precision in [:hour, :minute, :second] do
to_string(from, to, backend, options)
end
end
Expand Down Expand Up @@ -324,7 +324,7 @@ defmodule Cldr.DateTime.Interval do
end

def to_string!(%CalendarInterval{first: from, last: to, precision: precision}, backend, options)
when precision in [:hour, :minute] do
when precision in [:hour, :minute, :second] do
to_string!(from, to, backend, options)
end
end
Expand Down

0 comments on commit a347600

Please sign in to comment.