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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cbed125354afce1f4f269c650c3db7a8a7a43241
4
- data.tar.gz: 717dc6614479def8c2cd35c8e500f587c07f677f
3
+ metadata.gz: ea8b6d09729e76b571682a4826ccf1674dc55039
4
+ data.tar.gz: 12fc34ff5b0201462b2fc95ffca9603e3a6a7b36
5
5
  SHA512:
6
- metadata.gz: 8a01af67778a77412912f6db4860b1c0d1541a5e15d4afac1651d5d86602539afb8e63ce1e723c0f6a2caacaad617659bd2abc61e6d2737a66a4d9e9d4de62bd
7
- data.tar.gz: adaf7389ef47fe092ead9ccdc4d2a5bcd749cc19feb6e23f4a696fadf802d68a07adafca1b8ed23862ce0b7752cd002ef483e63d6d4f26bf484d02328fd2d55b
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 = ISO8601::Date.new '2010-01-01' # => #<ISO8601::Date: 2010-01-01>
14
- time = ISO8601::Time.new '10:30' # => #<ISO8601::Time: T10:30:00+00:00>
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 # => #<ISO8601::DateTime: 2010-01-01T10:30:00+00:00>
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 = ISO8601::Duration.new 'PT1H' # => #<ISO8601::Duration: PT1H>
25
- time = ISO8601::Time.new '10:30' # => #<ISO8601::Time: T10:30:00+00:00>
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 # => #<ISO8601::Time: T11:30:00+00:00>
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 = ISO8601::Duration.new 'P1D' # => #<ISO8601::Duration: P1D>
34
- date = ISO8601::Date.new '2010-01-01' # => #<ISO8601::Date: 2010-01-01>
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 # => #<ISO8601::Time: 2010-01-02>
36
+ date + duration # => #<ISO8601Basic::Time: 2010-01-02>
37
37
  ```
38
38
 
39
39
  All together now:
40
40
 
41
41
  ```ruby
42
- duration = ISO8601::Duration.new 'P1DT1H' # => #<ISO8601::Duration: P1DT1H>
43
- date_time = ISO8601::DateTime.new '2010-01-01T10:30' # => #<ISO8601::DateTime: 2010-01-01T10:30:00+00:00>
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 # => #<ISO8601::DateTime: 2010-01-02T11:30:00+00:00>
45
+ date_time + duration # => #<ISO8601Basic::DateTime: 2010-01-02T11:30:00+00:00>
46
46
  ```
@@ -1,9 +1,9 @@
1
1
  $:.push File.expand_path('../lib', __FILE__)
2
- require 'iso8601/version'
2
+ require 'iso8601_basic/version'
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'iso8601-basic'
6
- s.version = ISO8601::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'
@@ -0,0 +1,7 @@
1
+ require 'date'
2
+
3
+ require_relative 'iso8601_basic/version'
4
+ require_relative 'iso8601_basic/date'
5
+ require_relative 'iso8601_basic/time'
6
+ require_relative 'iso8601_basic/date_time'
7
+ require_relative 'iso8601_basic/duration'
@@ -1,4 +1,4 @@
1
- class ISO8601::Date < ::Date
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 ISO8601::Time
15
- ISO8601::DateTime.new year, month, day,
14
+ when ISO8601Basic::Time
15
+ ISO8601Basic::DateTime.new year, month, day,
16
16
  other.hour, other.minute, other.second, other.zone
17
- when ISO8601::Duration
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
- "#<ISO8601::Date: #{iso8601}>"
25
+ "#<ISO8601Basic::Date: #{iso8601}>"
26
26
  end
27
27
  end
@@ -1,4 +1,4 @@
1
- class ISO8601::DateTime < ::DateTime
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
- ISO8601::Date.new year, month, day
14
+ ISO8601Basic::Date.new year, month, day
15
15
  end
16
16
 
17
17
  def to_iso8601_time
18
- ISO8601::Time.new hour, minute, second, zone
18
+ ISO8601Basic::Time.new hour, minute, second, zone
19
19
  end
20
20
 
21
21
  def +(other)
22
22
  case other
23
- when ISO8601::Duration
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
- "#<ISO8601::DateTime: #{iso8601}>"
31
+ "#<ISO8601Basic::DateTime: #{iso8601}>"
32
32
  end
33
33
  end
@@ -1,4 +1,4 @@
1
- class ISO8601::Duration
1
+ class ISO8601Basic::Duration
2
2
 
3
3
  attr_reader :years, :months, :weeks, :days, :hours, :minutes, :seconds, :sign
4
4
 
@@ -1,4 +1,4 @@
1
- class ISO8601::Time < ::DateTime
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 ISO8601::Date
17
- ISO8601::DateTime.new other.year, other.month, other.day,
16
+ when ISO8601Basic::Date
17
+ ISO8601Basic::DateTime.new other.year, other.month, other.day,
18
18
  hour, minute, second, zone
19
- when ISO8601::Duration
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
- "#<ISO8601::Time: #{iso8601}>"
32
+ "#<ISO8601Basic::Time: #{iso8601}>"
33
33
  end
34
34
 
35
35
  def to_s
@@ -0,0 +1,3 @@
1
+ module ISO8601Basic
2
+ VERSION = '1.0.0'
3
+ end
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.1.1
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: 2014-08-19 00:00:00.000000000 Z
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/iso8601.rb
26
- - lib/iso8601/date.rb
27
- - lib/iso8601/date_time.rb
28
- - lib/iso8601/duration.rb
29
- - lib/iso8601/time.rb
30
- - lib/iso8601/version.rb
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.2.1
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:
@@ -1,7 +0,0 @@
1
- require 'date'
2
-
3
- require_relative 'iso8601/version'
4
- require_relative 'iso8601/date'
5
- require_relative 'iso8601/time'
6
- require_relative 'iso8601/date_time'
7
- require_relative 'iso8601/duration'
@@ -1,3 +0,0 @@
1
- module ISO8601
2
- VERSION = '0.1.1'
3
- end