iso8601-basic 0.1.1 → 1.0.0
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.
- checksums.yaml +4 -4
- data/README.md +12 -12
- data/iso8601-basic.gemspec +2 -2
- data/lib/iso8601_basic.rb +7 -0
- data/lib/{iso8601 → iso8601_basic}/date.rb +5 -5
- data/lib/{iso8601 → iso8601_basic}/date_time.rb +5 -5
- data/lib/{iso8601 → iso8601_basic}/duration.rb +1 -1
- data/lib/{iso8601 → iso8601_basic}/time.rb +5 -5
- data/lib/iso8601_basic/version.rb +3 -0
- metadata +9 -10
- data/lib/iso8601.rb +0 -7
- data/lib/iso8601/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea8b6d09729e76b571682a4826ccf1674dc55039
|
4
|
+
data.tar.gz: 12fc34ff5b0201462b2fc95ffca9603e3a6a7b36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d4f593012b1979c1a4d908b9c10f683c4a7236d3be8efe60109b4a1e1b21178a4050235e3f3e3fe446e9efd1170599df7ddfed94565c49eb1448e077513e6ee
|
7
|
+
data.tar.gz: 169732910100854f8562f37a392025687e075bf924c09288157fdeb10ccccbffe6139111b6cf9c75700b55926f251fe551b9bfdf7a719b0689bf0c594d0fced3
|
data/README.md
CHANGED
@@ -10,10 +10,10 @@ gem 'iso8601-basic', require 'iso8601'
|
|
10
10
|
## Joining date/time parts:
|
11
11
|
|
12
12
|
```ruby
|
13
|
-
date =
|
14
|
-
time =
|
13
|
+
date = ISO8601Basic::Date.new '2010-01-01' # => #<ISO8601Basic::Date: 2010-01-01>
|
14
|
+
time = ISO8601Basic::Time.new '10:30' # => #<ISO8601Basic::Time: T10:30:00+00:00>
|
15
15
|
|
16
|
-
date + time # => #<
|
16
|
+
date + time # => #<ISO8601Basic::DateTime: 2010-01-01T10:30:00+00:00>
|
17
17
|
```
|
18
18
|
|
19
19
|
## Working with durations:
|
@@ -21,26 +21,26 @@ date + time # => #<ISO8601::DateTime: 2010-01-01T10:30:00+00:00>
|
|
21
21
|
When working with times:
|
22
22
|
|
23
23
|
```ruby
|
24
|
-
duration =
|
25
|
-
time =
|
24
|
+
duration = ISO8601Basic::Duration.new 'PT1H' # => #<ISO8601Basic::Duration: PT1H>
|
25
|
+
time = ISO8601Basic::Time.new '10:30' # => #<ISO8601Basic::Time: T10:30:00+00:00>
|
26
26
|
|
27
|
-
time + duration # => #<
|
27
|
+
time + duration # => #<ISO8601Basic::Time: T11:30:00+00:00>
|
28
28
|
```
|
29
29
|
|
30
30
|
And with dates:
|
31
31
|
|
32
32
|
```ruby
|
33
|
-
duration =
|
34
|
-
date =
|
33
|
+
duration = ISO8601Basic::Duration.new 'P1D' # => #<ISO8601Basic::Duration: P1D>
|
34
|
+
date = ISO8601Basic::Date.new '2010-01-01' # => #<ISO8601Basic::Date: 2010-01-01>
|
35
35
|
|
36
|
-
date + duration # => #<
|
36
|
+
date + duration # => #<ISO8601Basic::Time: 2010-01-02>
|
37
37
|
```
|
38
38
|
|
39
39
|
All together now:
|
40
40
|
|
41
41
|
```ruby
|
42
|
-
duration =
|
43
|
-
date_time =
|
42
|
+
duration = ISO8601Basic::Duration.new 'P1DT1H' # => #<ISO8601Basic::Duration: P1DT1H>
|
43
|
+
date_time = ISO8601Basic::DateTime.new '2010-01-01T10:30' # => #<ISO8601Basic::DateTime: 2010-01-01T10:30:00+00:00>
|
44
44
|
|
45
|
-
date_time + duration # => #<
|
45
|
+
date_time + duration # => #<ISO8601Basic::DateTime: 2010-01-02T11:30:00+00:00>
|
46
46
|
```
|
data/iso8601-basic.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
$:.push File.expand_path('../lib', __FILE__)
|
2
|
-
require '
|
2
|
+
require 'iso8601_basic/version'
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'iso8601-basic'
|
6
|
-
s.version =
|
6
|
+
s.version = ISO8601Basic::VERSION
|
7
7
|
s.date = Time.now.strftime('%Y-%m-%d')
|
8
8
|
s.authors = ['Oliver Morgan']
|
9
9
|
s.email = 'olly@ticketinghub.com'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class ISO8601Basic::Date < ::Date
|
2
2
|
|
3
3
|
def self.new(*args)
|
4
4
|
case value = args[0]
|
@@ -11,10 +11,10 @@ class ISO8601::Date < ::Date
|
|
11
11
|
|
12
12
|
def +(other)
|
13
13
|
case other
|
14
|
-
when
|
15
|
-
|
14
|
+
when ISO8601Basic::Time
|
15
|
+
ISO8601Basic::DateTime.new year, month, day,
|
16
16
|
other.hour, other.minute, other.second, other.zone
|
17
|
-
when
|
17
|
+
when ISO8601Basic::Duration
|
18
18
|
{ years: [:>>, 12], months: [:>>, 1], weeks: [:+, 7], days: [:+, 1] }.reduce self do |date, (key, (action, factor))|
|
19
19
|
date.send action, other.to_h[key] * factor
|
20
20
|
end
|
@@ -22,6 +22,6 @@ class ISO8601::Date < ::Date
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def inspect
|
25
|
-
"#<
|
25
|
+
"#<ISO8601Basic::Date: #{iso8601}>"
|
26
26
|
end
|
27
27
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class ISO8601Basic::DateTime < ::DateTime
|
2
2
|
|
3
3
|
def self.new(*args)
|
4
4
|
case value = args[0]
|
@@ -11,16 +11,16 @@ class ISO8601::DateTime < ::DateTime
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_iso8601_date
|
14
|
-
|
14
|
+
ISO8601Basic::Date.new year, month, day
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_iso8601_time
|
18
|
-
|
18
|
+
ISO8601Basic::Time.new hour, minute, second, zone
|
19
19
|
end
|
20
20
|
|
21
21
|
def +(other)
|
22
22
|
case other
|
23
|
-
when
|
23
|
+
when ISO8601Basic::Duration
|
24
24
|
date = to_iso8601_date + other
|
25
25
|
time = to_iso8601_time + other
|
26
26
|
date + time
|
@@ -28,6 +28,6 @@ class ISO8601::DateTime < ::DateTime
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def inspect
|
31
|
-
"#<
|
31
|
+
"#<ISO8601Basic::DateTime: #{iso8601}>"
|
32
32
|
end
|
33
33
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class ISO8601Basic::Time < ::DateTime
|
2
2
|
|
3
3
|
def self.new(*args)
|
4
4
|
case value = args[0]
|
@@ -13,10 +13,10 @@ class ISO8601::Time < ::DateTime
|
|
13
13
|
|
14
14
|
def +(other)
|
15
15
|
case other
|
16
|
-
when
|
17
|
-
|
16
|
+
when ISO8601Basic::Date
|
17
|
+
ISO8601Basic::DateTime.new other.year, other.month, other.day,
|
18
18
|
hour, minute, second, zone
|
19
|
-
when
|
19
|
+
when ISO8601Basic::Duration
|
20
20
|
seconds = [:hours, :minutes, :seconds].collect do |key|
|
21
21
|
{ seconds: 1, minutes: 60, hours: 3600 }[key] * other.to_h[key]
|
22
22
|
end.inject :+
|
@@ -29,7 +29,7 @@ class ISO8601::Time < ::DateTime
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def inspect
|
32
|
-
"#<
|
32
|
+
"#<ISO8601Basic::Time: #{iso8601}>"
|
33
33
|
end
|
34
34
|
|
35
35
|
def to_s
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iso8601-basic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Morgan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Very basic implementation of the ISO8601 spec - http://en.wikipedia.org/wiki/ISO_8601
|
14
14
|
email: olly@ticketinghub.com
|
@@ -22,12 +22,12 @@ files:
|
|
22
22
|
- README.md
|
23
23
|
- Rakefile
|
24
24
|
- iso8601-basic.gemspec
|
25
|
-
- lib/
|
26
|
-
- lib/
|
27
|
-
- lib/
|
28
|
-
- lib/
|
29
|
-
- lib/
|
30
|
-
- lib/
|
25
|
+
- lib/iso8601_basic.rb
|
26
|
+
- lib/iso8601_basic/date.rb
|
27
|
+
- lib/iso8601_basic/date_time.rb
|
28
|
+
- lib/iso8601_basic/duration.rb
|
29
|
+
- lib/iso8601_basic/time.rb
|
30
|
+
- lib/iso8601_basic/version.rb
|
31
31
|
homepage: https://github.com/ticketinghub/iso8601-basic
|
32
32
|
licenses:
|
33
33
|
- MIT
|
@@ -48,9 +48,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
48
|
version: '0'
|
49
49
|
requirements: []
|
50
50
|
rubyforge_project:
|
51
|
-
rubygems_version: 2.
|
51
|
+
rubygems_version: 2.5.1
|
52
52
|
signing_key:
|
53
53
|
specification_version: 4
|
54
54
|
summary: Very basic implementation of the ISO8601 spec - http://en.wikipedia.org/wiki/ISO_8601
|
55
55
|
test_files: []
|
56
|
-
has_rdoc:
|
data/lib/iso8601.rb
DELETED
data/lib/iso8601/version.rb
DELETED