Skip to content

Commit

Permalink
Fixes for new time formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwalker committed Aug 13, 2015
1 parent f546a10 commit 180f262
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/format/time/formatters/default.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ defmodule Timex.Format.Time.Formatters.Default do
cond do
seconds >= @year -> deconstruct({rem(seconds, @year), us}, [{:years, div(seconds, @year)} | components])
seconds >= @month -> deconstruct({rem(seconds, @month), us}, [{:months, div(seconds, @month)} | components])
seconds >= @week -> deconstruct({rem(seconds, @week), us}, [{:weeks, div(seconds, @week)} | components])
seconds >= @day -> deconstruct({rem(seconds, @day), us}, [{:days, div(seconds, @day)} | components])
seconds >= @hour -> deconstruct({rem(seconds, @hour), us}, [{:hours, div(seconds, @hour)} | components])
seconds >= @minute -> deconstruct({rem(seconds, @minute), us}, [{:minutes, div(seconds, @minute)} | components])
true -> get_fractional_seconds(seconds, us, components)
end
end
defp deconstruct({seconds, us}, components) do
get_fractional_seconds(seconds, us, components)
end
defp get_fractional_seconds(seconds, 0, components), do: deconstruct({0, 0}, [{:seconds, seconds} | components])
defp get_fractional_seconds(seconds, micro, components) when micro > 0 do
msecs = {0, 0, micro} |> Time.abs |> Time.to_msecs
Expand Down

0 comments on commit 180f262

Please sign in to comment.