ruby-duration 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
data/lib/duration.rb CHANGED
@@ -66,6 +66,11 @@ class Duration
66
66
  def <=>(other)
67
67
  @total <=> other.to_i
68
68
  end
69
+
70
+ # Formats a duration in ISO8601. See http://en.wikipedia.org/wiki/ISO_8601#Durations
71
+ def iso8601
72
+ format("P%wW%dDT%hH%mM%sS")
73
+ end
69
74
 
70
75
  # Format a duration into a human-readable string.
71
76
  #
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruby-duration}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jose Peleteiro"]
@@ -32,5 +32,10 @@ class TestDuration < MiniTest::Unit::TestCase
32
32
  d = Duration.new(:weeks => 1, :days => 1, :hours => 1, :minutes => 1, :seconds => 1)
33
33
  assert_equal("1 week 1 day 1 hour 1 minute 1 second", d.format("%w %~w %d %~d %h %~h %m %~m %s %~s"))
34
34
  end
35
+
36
+ def test_iso_8601
37
+ d = Duration.new(:weeks => 1, :days => 2, :hours => 3, :minutes => 4, :seconds => 5)
38
+ assert_equal("P1W2DT3H4M5S", d.iso8601)
39
+ end
35
40
 
36
41
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-duration
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jose Peleteiro