ecto_interval
ecto_interval copied to clipboard
Better string formatting
At the moment string formatting isn't always the most helpful:
iex(34)> to_string(%Interval{months: 1, days: 2, secs: 3665})
"Every 1 months 2 days 3665 seconds"
I've come up with a function that uses Timex.Duration
to give a better representation:
iex(37)> format_interval(%Interval{months: 1, days: 2, secs: 3665})
"1 month 2 days 1 hour 1 minute 5 seconds"
I appreciate that we don't want ecto_interval to depend on Timex but if there's interest maybe I can come up with another function that doesn't depend on it and submit a PR.