Skip to content

Better string formatting #7

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions