iso8601 0.10.0 → 0.12.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.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +13 -20
- data/iso8601.gemspec +7 -46
- data/lib/iso8601/date_time.rb +2 -2
- data/lib/iso8601/duration.rb +7 -0
- data/lib/iso8601/months.rb +2 -1
- data/lib/iso8601/version.rb +1 -1
- data/lib/iso8601/years.rb +2 -1
- metadata +15 -44
- data/CHANGELOG.md +0 -102
- data/Rakefile +0 -1
- data/docs/date-time.md +0 -86
- data/docs/duration.md +0 -76
- data/docs/time-interval.md +0 -120
- data/spec/iso8601/date_spec.rb +0 -91
- data/spec/iso8601/date_time_spec.rb +0 -154
- data/spec/iso8601/days_spec.rb +0 -44
- data/spec/iso8601/duration_spec.rb +0 -275
- data/spec/iso8601/hours_spec.rb +0 -44
- data/spec/iso8601/minutes_spec.rb +0 -44
- data/spec/iso8601/months_spec.rb +0 -94
- data/spec/iso8601/seconds_spec.rb +0 -44
- data/spec/iso8601/time_interval_spec.rb +0 -509
- data/spec/iso8601/time_spec.rb +0 -110
- data/spec/iso8601/weeks_spec.rb +0 -46
- data/spec/iso8601/years_spec.rb +0 -70
- data/spec/spec_helper.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63fc30058203b81b163c0e43e6752493988e104a76b2fcd6c52eba5905cd5ec3
|
4
|
+
data.tar.gz: 990d117c3c06599abf7306da203fa23efadc1215d40eebf0f9a54da8dd30cf97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b84622859b9da1598fe29879aff66aeed4aaa560af9ecade7d48fbf4ae6e40a0668dadd528690f0c1039317f726925f3656414a6a4ac38658509edfbf8c793b3
|
7
|
+
data.tar.gz: 9719addba3e3536ecec660b791f65203332610eed991db6ca97cabf25ae186569ee82bb5ca63fc52ee76de15cd2e76c27bc403af0a1844978c377194b06c3907
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# ISO8601
|
2
|
+
|
3
|
+
**[New maintainer wanted](https://github.com/arnau/ISO8601/issues/50)**
|
2
4
|
|
3
5
|
Version 0.9.0 is **not compatible** with previous versions. Atoms and Durations
|
4
6
|
changed their interface when treating base dates so it is only applied when
|
@@ -18,13 +20,11 @@ times) standard.
|
|
18
20
|
## Build status
|
19
21
|
|
20
22
|
[](http://travis-ci.org/arnau/ISO8601/)
|
21
|
-
[](https://gemnasium.com/arnau/ISO8601)
|
22
23
|
[](http://badge.fury.io/rb/iso8601)
|
23
24
|
|
24
25
|
## Supported versions
|
25
26
|
|
26
27
|
* MRI 2.x
|
27
|
-
* JRuby 9
|
28
28
|
|
29
29
|
## Documentation
|
30
30
|
|
@@ -38,26 +38,18 @@ take a look to the implementation notes:
|
|
38
38
|
|
39
39
|
## Testing
|
40
40
|
|
41
|
+
Install a Ruby version. E.g. you can install Ruby 2.7 with:
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
$ make install
|
46
|
-
$ make test
|
47
|
-
|
48
|
-
You can alse target specific runtimes:
|
49
|
-
|
50
|
-
$ make mri-test
|
51
|
-
$ make jruby-test
|
43
|
+
```
|
44
|
+
$ nix-shell
|
45
|
+
```
|
52
46
|
|
53
|
-
|
54
|
-
|
55
|
-
The old fashion way:
|
56
|
-
|
57
|
-
# Install a Ruby flavour
|
58
|
-
$ bundle install
|
59
|
-
$ bundle exec rspec
|
47
|
+
Then
|
60
48
|
|
49
|
+
```
|
50
|
+
$ bundle install
|
51
|
+
$ bundle exec rspec
|
52
|
+
```
|
61
53
|
|
62
54
|
## Contributing
|
63
55
|
|
@@ -65,6 +57,7 @@ The old fashion way:
|
|
65
57
|
|
66
58
|
Please see [CONTRIBUTING.md](./CONTRIBUTING.md)
|
67
59
|
|
60
|
+
|
68
61
|
## License
|
69
62
|
|
70
63
|
Arnau Siches under the [MIT License](https://github.com/arnau/ISO8601/blob/master/LICENSE)
|
data/iso8601.gemspec
CHANGED
@@ -16,53 +16,14 @@ Gem::Specification.new do |s|
|
|
16
16
|
and times) standard.
|
17
17
|
DESC
|
18
18
|
s.license = 'MIT'
|
19
|
-
s.
|
20
|
-
s.
|
21
|
-
CONTRIBUTING.md
|
22
|
-
Gemfile
|
23
|
-
LICENSE
|
24
|
-
README.md
|
25
|
-
Rakefile
|
26
|
-
iso8601.gemspec
|
27
|
-
docs/date-time.md
|
28
|
-
docs/duration.md
|
29
|
-
docs/time-interval.md
|
30
|
-
lib/iso8601.rb
|
31
|
-
lib/iso8601/atomic.rb
|
32
|
-
lib/iso8601/date.rb
|
33
|
-
lib/iso8601/date_time.rb
|
34
|
-
lib/iso8601/days.rb
|
35
|
-
lib/iso8601/duration.rb
|
36
|
-
lib/iso8601/errors.rb
|
37
|
-
lib/iso8601/hours.rb
|
38
|
-
lib/iso8601/minutes.rb
|
39
|
-
lib/iso8601/months.rb
|
40
|
-
lib/iso8601/seconds.rb
|
41
|
-
lib/iso8601/time.rb
|
42
|
-
lib/iso8601/time_interval.rb
|
43
|
-
lib/iso8601/version.rb
|
44
|
-
lib/iso8601/weeks.rb
|
45
|
-
lib/iso8601/years.rb
|
46
|
-
spec/iso8601/date_spec.rb
|
47
|
-
spec/iso8601/date_time_spec.rb
|
48
|
-
spec/iso8601/days_spec.rb
|
49
|
-
spec/iso8601/duration_spec.rb
|
50
|
-
spec/iso8601/hours_spec.rb
|
51
|
-
spec/iso8601/minutes_spec.rb
|
52
|
-
spec/iso8601/months_spec.rb
|
53
|
-
spec/iso8601/seconds_spec.rb
|
54
|
-
spec/iso8601/time_interval_spec.rb
|
55
|
-
spec/iso8601/time_spec.rb
|
56
|
-
spec/iso8601/weeks_spec.rb
|
57
|
-
spec/iso8601/years_spec.rb
|
58
|
-
spec/spec_helper.rb]
|
59
|
-
s.test_files = s.files.grep(%r{^spec/})
|
19
|
+
s.files = %w{LICENSE README.md CONTRIBUTING.md} + `git ls-files`.split("\n").select { |f| f =~ %r{^(?:lib/)}i }
|
20
|
+
s.test_files = %w{iso8601.gemspec Gemfile} + `git ls-files`.split("\n").select { |f| f =~ %r{^(?:specs/)}i }
|
60
21
|
s.require_paths = ['lib']
|
61
22
|
|
62
|
-
s.
|
23
|
+
s.metadata["yard.run"] = "yri"
|
63
24
|
s.required_ruby_version = '>= 2.0.0'
|
64
|
-
s.add_development_dependency 'rspec', '~> 3.
|
65
|
-
s.add_development_dependency 'rubocop', '~> 0.
|
66
|
-
s.add_development_dependency 'pry', '~> 0.
|
67
|
-
s.add_development_dependency 'pry-doc', '~>
|
25
|
+
s.add_development_dependency 'rspec', '~> 3.9'
|
26
|
+
s.add_development_dependency 'rubocop', '~> 0.85'
|
27
|
+
s.add_development_dependency 'pry', '~> 0.13.1'
|
28
|
+
s.add_development_dependency 'pry-doc', '~> 1.1.0'
|
68
29
|
end
|
data/lib/iso8601/date_time.rb
CHANGED
@@ -47,9 +47,9 @@ module ISO8601
|
|
47
47
|
##
|
48
48
|
# Converts DateTime to a formated string
|
49
49
|
def to_s
|
50
|
-
second_format =
|
50
|
+
second_format = (second % 1).zero? ? '%02d' : '%04.1f'
|
51
51
|
|
52
|
-
format("%04d-%02d-%02dT%02d:%02d:#{second_format}
|
52
|
+
format("%04d-%02d-%02dT%02d:%02d:#{second_format}%s", *atoms)
|
53
53
|
end
|
54
54
|
|
55
55
|
##
|
data/lib/iso8601/duration.rb
CHANGED
@@ -125,6 +125,13 @@ module ISO8601
|
|
125
125
|
(to_seconds == fetch_seconds(other))
|
126
126
|
end
|
127
127
|
|
128
|
+
##
|
129
|
+
#
|
130
|
+
# @return [ISO8601::Duration]
|
131
|
+
def -@
|
132
|
+
seconds_to_iso(-to_seconds)
|
133
|
+
end
|
134
|
+
|
128
135
|
##
|
129
136
|
# @param [ISO8601::Duration] other The duration to compare
|
130
137
|
#
|
data/lib/iso8601/months.rb
CHANGED
@@ -60,6 +60,7 @@ module ISO8601
|
|
60
60
|
|
61
61
|
private
|
62
62
|
|
63
|
+
# rubocop:disable Metrics/AbcSize
|
63
64
|
def calculation(atom, base)
|
64
65
|
initial = base.month + atom
|
65
66
|
if initial <= 0
|
@@ -75,7 +76,7 @@ module ISO8601
|
|
75
76
|
else
|
76
77
|
month = initial <= 12 ? initial : (initial % 12)
|
77
78
|
month = 12 if month.zero?
|
78
|
-
year = base.year
|
79
|
+
year = initial <= 12 ? base.year : base.year + (initial / 12).to_i
|
79
80
|
end
|
80
81
|
|
81
82
|
(::Time.utc(year, month) - ::Time.utc(base.year, base.month)) / atom
|
data/lib/iso8601/version.rb
CHANGED
data/lib/iso8601/years.rb
CHANGED
@@ -51,10 +51,11 @@ module ISO8601
|
|
51
51
|
# the year length.
|
52
52
|
#
|
53
53
|
# @return [Numeric]
|
54
|
+
# rubocop:disable Metrics/AbcSize
|
54
55
|
def to_seconds(base = nil)
|
55
56
|
valid_base?(base)
|
56
57
|
return factor(base) * atom if base.nil?
|
57
|
-
target = ::Time.
|
58
|
+
target = ::Time.new(base.year + atom.to_i, base.month, base.day, base.hour, base.minute, base.second, base.zone)
|
58
59
|
|
59
60
|
target - base.to_time
|
60
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iso8601
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arnau Siches
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,56 +16,56 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.9'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.85'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.85'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pry
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.13.1
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.13.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry-doc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.1.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.1.0
|
69
69
|
description: |2
|
70
70
|
ISO8601 is a simple implementation in Ruby of the ISO 8601 (Data elements and
|
71
71
|
interchange formats - Information interchange - Representation of dates
|
@@ -75,15 +75,10 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
-
- CHANGELOG.md
|
79
78
|
- CONTRIBUTING.md
|
80
79
|
- Gemfile
|
81
80
|
- LICENSE
|
82
81
|
- README.md
|
83
|
-
- Rakefile
|
84
|
-
- docs/date-time.md
|
85
|
-
- docs/duration.md
|
86
|
-
- docs/time-interval.md
|
87
82
|
- iso8601.gemspec
|
88
83
|
- lib/iso8601.rb
|
89
84
|
- lib/iso8601/atomic.rb
|
@@ -101,23 +96,11 @@ files:
|
|
101
96
|
- lib/iso8601/version.rb
|
102
97
|
- lib/iso8601/weeks.rb
|
103
98
|
- lib/iso8601/years.rb
|
104
|
-
- spec/iso8601/date_spec.rb
|
105
|
-
- spec/iso8601/date_time_spec.rb
|
106
|
-
- spec/iso8601/days_spec.rb
|
107
|
-
- spec/iso8601/duration_spec.rb
|
108
|
-
- spec/iso8601/hours_spec.rb
|
109
|
-
- spec/iso8601/minutes_spec.rb
|
110
|
-
- spec/iso8601/months_spec.rb
|
111
|
-
- spec/iso8601/seconds_spec.rb
|
112
|
-
- spec/iso8601/time_interval_spec.rb
|
113
|
-
- spec/iso8601/time_spec.rb
|
114
|
-
- spec/iso8601/weeks_spec.rb
|
115
|
-
- spec/iso8601/years_spec.rb
|
116
|
-
- spec/spec_helper.rb
|
117
99
|
homepage: https://github.com/arnau/ISO8601
|
118
100
|
licenses:
|
119
101
|
- MIT
|
120
|
-
metadata:
|
102
|
+
metadata:
|
103
|
+
yard.run: yri
|
121
104
|
post_install_message:
|
122
105
|
rdoc_options: []
|
123
106
|
require_paths:
|
@@ -133,22 +116,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
116
|
- !ruby/object:Gem::Version
|
134
117
|
version: '0'
|
135
118
|
requirements: []
|
136
|
-
|
137
|
-
rubygems_version: 2.7.3
|
119
|
+
rubygems_version: 3.1.2
|
138
120
|
signing_key:
|
139
121
|
specification_version: 4
|
140
122
|
summary: Ruby parser to work with ISO 8601 dateTimes and durations - http://en.wikipedia.org/wiki/ISO_8601
|
141
123
|
test_files:
|
142
|
-
-
|
143
|
-
-
|
144
|
-
- spec/iso8601/days_spec.rb
|
145
|
-
- spec/iso8601/duration_spec.rb
|
146
|
-
- spec/iso8601/hours_spec.rb
|
147
|
-
- spec/iso8601/minutes_spec.rb
|
148
|
-
- spec/iso8601/months_spec.rb
|
149
|
-
- spec/iso8601/seconds_spec.rb
|
150
|
-
- spec/iso8601/time_interval_spec.rb
|
151
|
-
- spec/iso8601/time_spec.rb
|
152
|
-
- spec/iso8601/weeks_spec.rb
|
153
|
-
- spec/iso8601/years_spec.rb
|
154
|
-
- spec/spec_helper.rb
|
124
|
+
- iso8601.gemspec
|
125
|
+
- Gemfile
|
data/CHANGELOG.md
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
## 0.10.0
|
2
|
-
|
3
|
-
* Fix `TimeInterval` with `<duration>/<end>` patterns and leap years.
|
4
|
-
* Fix decimal fractions on date atoms. **WARNING** some duration patterns are
|
5
|
-
no longer valid.
|
6
|
-
|
7
|
-
## 0.9.1
|
8
|
-
|
9
|
-
* Fix `Duration#to_pattern` for negative durations based on a `Numeric` (thanks @figwit).
|
10
|
-
|
11
|
-
## 0.9.0
|
12
|
-
|
13
|
-
This version is **not compatible** with previous versions. Atoms and Durations
|
14
|
-
changed their interface when treating base dates so it is only applied when
|
15
|
-
computing the Atom length (e.g. `#to_seconds`). As a consequence, it is no
|
16
|
-
longer possible to do operations like `DateTime + Duration`.
|
17
|
-
|
18
|
-
* Add time intervals (thanks @Angelmmiguel).
|
19
|
-
* Remove `Duration#to_i`.
|
20
|
-
* Change `Duration#to_seconds` to accept a base `DateTime`.
|
21
|
-
* Remove duration dependency on a base date on the instance level.
|
22
|
-
* Change `Years#to_seconds` and `Months#to_seconds` to accept a base `DateTime`.
|
23
|
-
* Remove atom dependency on a base date on the instance level.
|
24
|
-
* Add `Atomic` mixin.
|
25
|
-
* Remove `Atom` abstract class.
|
26
|
-
* Allow `ISO8601::Duration` to perform operations with `Numeric` (thanks @Angelmmiguel).
|
27
|
-
|
28
|
-
## 0.8.7
|
29
|
-
|
30
|
-
* Make `Atom` comparable with the same kind (thanks @glassbead0).
|
31
|
-
* Fix #18 document interfaces to core date/time classes.
|
32
|
-
|
33
|
-
## 0.8.6
|
34
|
-
|
35
|
-
* Fix #26 operations with Date, DateTime and Time with Duration (e.g. `ISO8601::DateTime.new('2012-07-07T20:20:20Z') - ISO8601::Duration.new('PT10M')`).
|
36
|
-
* Fix #25 accept time components with timezone and only hour component (e.g. `ISO8601::Time.new('T10+01:00')`).
|
37
|
-
* Fix Docker image for testing and inspecting.
|
38
|
-
|
39
|
-
## 0.8.5
|
40
|
-
|
41
|
-
* Fix `DateTime#hash`
|
42
|
-
* Fix `DateTime#second` and `Time#second` precision. Now it's rounded to the
|
43
|
-
first decimal.
|
44
|
-
|
45
|
-
## 0.8.4
|
46
|
-
|
47
|
-
* Remove unwanted log.
|
48
|
-
|
49
|
-
## 0.8.3
|
50
|
-
|
51
|
-
* Fix partial time patterns with timezone: `PThh:mmZ`, `PThhZ`.
|
52
|
-
|
53
|
-
## 0.8.2
|
54
|
-
|
55
|
-
* Fix time components using comma (,) as a decimal separator.
|
56
|
-
|
57
|
-
## 0.8.1
|
58
|
-
|
59
|
-
* Fix durations using comma (,) as a decimal separator.
|
60
|
-
|
61
|
-
## 0.8.0
|
62
|
-
|
63
|
-
* `DateTime` has hash identity by value.
|
64
|
-
* `Time` has hash identity by value.
|
65
|
-
* `Date` has hash identity by value.
|
66
|
-
* `Duration` has hash identity by value.
|
67
|
-
* `Atom` has hash identity by value.
|
68
|
-
* `Atom#value` returns either an integer or a float.
|
69
|
-
* `Atom#to_s` returns a valid ISO8601 subpattern.
|
70
|
-
|
71
|
-
## 0.7.0
|
72
|
-
|
73
|
-
* Add decimal fractions for any component in a duration.
|
74
|
-
* Add a catch all `ISO8601::Errors::StandardError`.
|
75
|
-
* Add support for comma (`,`) as a separator for duration decimal fractions.
|
76
|
-
|
77
|
-
## 0.6.0
|
78
|
-
|
79
|
-
* Add `#hash` to `Duration`, `Date`, `Time` and `DateTime`.
|
80
|
-
|
81
|
-
## 0.5.2
|
82
|
-
|
83
|
-
* Fix `DateTime` when handling empty strings.
|
84
|
-
|
85
|
-
## 0.5.1
|
86
|
-
|
87
|
-
* Fix durations with sign.
|
88
|
-
|
89
|
-
## 0.5.0
|
90
|
-
|
91
|
-
* Drop support for Ruby 1.8.7.
|
92
|
-
* Add support for Rubinius 2.
|
93
|
-
* `ISO8601::DateTime#century` no longer exists. Truncated representations were
|
94
|
-
removed in ISO 8601:2004.
|
95
|
-
* `ISO8601::DateTime#zone` delegates to core `DateTime#zone`.
|
96
|
-
* `ISO8601::DateTime#timezone` no longer exists. Now it delegates to
|
97
|
-
`DateTime#zone`.
|
98
|
-
* A date can have sign: `-1000-01-01`, `+2014-05-06T10:11:12Z`.
|
99
|
-
* A date time can be converted to an array of atoms with `#to_a`.
|
100
|
-
* Ordinal dates supported.
|
101
|
-
* A date component is represented by `ISO8601::Date`.
|
102
|
-
* Week date pattern (YYYY-Wdww, YYYY-Www-D).
|