Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string output #24

Open
smcabrera opened this issue Mar 2, 2015 · 1 comment
Open

string output #24

smcabrera opened this issue Mar 2, 2015 · 1 comment

Comments

@smcabrera
Copy link
Contributor

Currently outputting as a string gives you the following:

Duration.new(1000).to_s
=> "#<Duration:0x007fc7f28f5ce8>"

I'd love to implement a to_s function that would cause durations to output a little more like the way the Time class works:

Time.new.to_s
=> "2015-03-02 17:59:27 -0500"

Something like this:

Duration.new(1000).to_s
=> "00:16:40"

The only issue I can think of is that you allow for days and weeks and I'm not sure what format those should be outputted in...thoughts?

@lacostenycoder
Copy link

We already have a problem that this gem doesn't correctly support ISO 8061 Duration, for example calling this method should return the same value as the input but it doesn't.

irb(main):004:0>  d = Duration.new('P3Y6M4DT12H30M5S')
=> #<Duration:0x007fdb4ea67df0 @seconds=5, @negative=false, @total=110766605, @weeks=183, @days=1, @hours=0, @minutes=30>
irb(main):005:0> d.iso8601
=> "P1282DT30M5S"

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

No branches or pull requests

3 participants