ruby-duration 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
data/lib/duration.rb CHANGED
@@ -64,21 +64,17 @@ class Duration
64
64
  # Formats a duration in ISO8601.
65
65
  # @see http://en.wikipedia.org/wiki/ISO_8601#Durations
66
66
  def iso8601
67
- output = ''
68
-
69
- if days > 0 || weeks > 0
70
- output << 'P'
71
- output << "#{weeks}W" if weeks > 0
72
- output << "#{days}D" if days > 0
73
- end
74
-
67
+ output = 'P'
68
+
69
+ output << "#{weeks}W" if weeks > 0
70
+ output << "#{days}D" if days > 0
75
71
  if seconds > 0 || minutes > 0 || hours > 0
76
72
  output << 'T'
77
73
  output << "#{hours}H" if hours > 0
78
74
  output << "#{minutes}M" if minutes > 0
79
75
  output << "#{seconds}S" if seconds > 0
80
76
  end
81
-
77
+
82
78
  output
83
79
  end
84
80
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruby-duration}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
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"]
@@ -38,17 +38,17 @@ describe "Duration" do
38
38
  describe "#iso_6801" do
39
39
  it "should format seconds" do
40
40
  d = Duration.new(:seconds => 1)
41
- assert_equal("T1S", d.iso8601)
41
+ assert_equal("PT1S", d.iso8601)
42
42
  end
43
43
 
44
44
  it "should format minutes" do
45
45
  d = Duration.new(:minutes => 1)
46
- assert_equal("T1M", d.iso8601)
46
+ assert_equal("PT1M", d.iso8601)
47
47
  end
48
48
 
49
49
  it "should format hours" do
50
50
  d = Duration.new(:hours => 1)
51
- assert_equal("T1H", d.iso8601)
51
+ assert_equal("PT1H", d.iso8601)
52
52
  end
53
53
 
54
54
  it "should format days" do
@@ -72,7 +72,7 @@ describe "Duration" do
72
72
  assert_equal("P1W2D", d.iso8601)
73
73
 
74
74
  d = Duration.new(:hours => 1, :seconds => 30)
75
- assert_equal("T1H30S", d.iso8601)
75
+ assert_equal("PT1H30S", d.iso8601)
76
76
  end
77
77
 
78
78
  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: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jose Peleteiro