Archive for June, 2009
Splash
Ruby Duration
Duration.new recieves a string describing a duration of time, and converts it into: seconds, and a standard readable format.
Or, you can pass Duration.new an integer representing seconds, and receive the same standard readable format.
Usage:
Passing a String
duration = Duration.new("2weeks 8 hr 30m")
duration.seconds # => 1240200
duration.readable # => "2 weeks, 8 hours and 30 [...]