ruby-duration 0.1.4 → 0.1.5
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 +1 -1
- data/lib/duration.rb +5 -0
- data/ruby-duration.gemspec +1 -1
- data/test/test_duration.rb +5 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
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
|
#
|
data/ruby-duration.gemspec
CHANGED
data/test/test_duration.rb
CHANGED
@@ -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:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jose Peleteiro
|