edtf 3.3.0 → 4.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 +143 -117
- data/lib/edtf/date.rb +39 -2
- data/lib/edtf/epoch.rb +3 -1
- data/lib/edtf/interval.rb +40 -15
- data/lib/edtf/parser.rb +33 -33
- data/lib/edtf/parser.y +32 -32
- data/lib/edtf/season.rb +10 -2
- data/lib/edtf/set.rb +15 -1
- data/lib/edtf/uncertainty.rb +7 -8
- data/lib/edtf/version.rb +1 -1
- metadata +26 -57
- data/.github/workflows/ci.yml +0 -44
- data/.gitignore +0 -8
- data/.rspec +0 -3
- data/.simplecov +0 -19
- data/Gemfile +0 -20
- data/Rakefile +0 -41
- data/cucumber.yml +0 -1
- data/edtf.gemspec +0 -29
- data/features/parser/date_times.feature +0 -41
- data/features/parser/dates.feature +0 -89
- data/features/parser/intervals.feature +0 -18
- data/features/parser/precision.feature +0 -14
- data/features/parser/uncertain_or_approximate.feature +0 -129
- data/features/parser/unspecified.feature +0 -34
- data/features/print/level_0_edtf.feature +0 -79
- data/features/print/level_1_edtf.feature +0 -137
- data/features/print/level_2_edtf.feature +0 -39
- data/features/print/uncertain_or_approximate.feature +0 -131
- data/features/step_definitions/edtf_steps.rb +0 -150
- data/features/support/env.rb +0 -13
- data/spec/edtf/date_spec.rb +0 -245
- data/spec/edtf/epoch_spec.rb +0 -88
- data/spec/edtf/interval_spec.rb +0 -308
- data/spec/edtf/parser_spec.rb +0 -427
- data/spec/edtf/season_spec.rb +0 -111
- data/spec/edtf/set_spec.rb +0 -107
- data/spec/edtf/uncertainty_spec.rb +0 -296
- data/spec/spec_helper.rb +0 -15
data/spec/edtf/date_spec.rb
DELETED
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
describe 'Date/DateTime' do
|
|
2
|
-
|
|
3
|
-
describe 'class methods' do
|
|
4
|
-
it 'responds to edtf' do
|
|
5
|
-
expect(Date).to respond_to(:edtf)
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
describe 'instance methods' do
|
|
10
|
-
[:uncertain?, :approximate?, :unspecified?, :uncertain, :approximate, :unspecified].each do |method|
|
|
11
|
-
it "responds to #{method}" do
|
|
12
|
-
expect(Date.new.respond_to?(method)).to eq(true)
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
describe '#dup' do
|
|
18
|
-
let(:date) { Date.edtf('2004-09?~') }
|
|
19
|
-
|
|
20
|
-
it 'copies all date values' do
|
|
21
|
-
date.dup.to_s == '2004-09-01'
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'copies uncertainty' do
|
|
25
|
-
expect(date.dup).to be_uncertain
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'copies approximate' do
|
|
29
|
-
expect(date.dup).to be_approximate
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'copies precision' do
|
|
33
|
-
expect(date.dup.precision).to eq(:month)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'copies uncertainty by value' do
|
|
37
|
-
expect { date.dup.certain! }.not_to change { date.uncertain? }
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
describe 'precisions' do
|
|
43
|
-
let(:date) { Date.today }
|
|
44
|
-
|
|
45
|
-
it 'has day precision by default' do
|
|
46
|
-
expect(date).to be_day_precision
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it '#day_precison returns a new date object' do
|
|
50
|
-
expect(date.day_precision).not_to equal(date)
|
|
51
|
-
expect(date.day_precision).to eq(date)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
describe '#negate' do
|
|
58
|
-
let(:date) { Date.edtf('2004?') }
|
|
59
|
-
|
|
60
|
-
it 'returns a new date with the negated year' do
|
|
61
|
-
expect(date.negate.year).to eq(date.year * -1)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it 'returns a new date with the same month' do
|
|
65
|
-
expect(date.negate.month).to eq(date.month)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it 'returns a new date with the same day' do
|
|
69
|
-
expect(date.negate.day).to eq(date.day)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it 'returns a new date with the same precision' do
|
|
73
|
-
expect(date.negate.precision).to eq(date.precision)
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
describe '#succ' do
|
|
78
|
-
|
|
79
|
-
it 'the successor of 2004 is 2005' do
|
|
80
|
-
expect(Date.edtf('2004').succ.year).to eq(2005)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it 'the successor of 2004-03 is 2004-04' do
|
|
84
|
-
expect(Date.edtf('2004-03').succ.strftime('%Y-%m')).to eq('2004-04')
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it 'the successor of 2004-03-01 is 2004-03-02' do
|
|
88
|
-
expect(Date.edtf('2004-03-01').succ.strftime('%Y-%m-%d')).to eq('2004-03-02')
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "the successor of 1999 has year precision" do
|
|
92
|
-
expect(Date.edtf('1999').succ).to be_year_precision
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
describe '#next' do
|
|
98
|
-
|
|
99
|
-
it 'returns the successor when given no argument' do
|
|
100
|
-
expect(Date.edtf('1999').next[0].year).to eq(2000)
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it 'returns an array of the next 3 elements when passed 3 as an argument' do
|
|
104
|
-
Date.edtf('1999').next(3).map(&:year) == [2000, 2001, 2002]
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
describe '#change' do
|
|
111
|
-
let(:date) { Date.edtf('2004-09?~') }
|
|
112
|
-
|
|
113
|
-
it 'returns a copy of the date if given empty option hash' do
|
|
114
|
-
expect(date.change({})).to eq(date)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it 'the returned copy is not identical at object level' do
|
|
118
|
-
expect(date.change({})).not_to equal(date)
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
describe 'when given a new year' do
|
|
122
|
-
let(:changeset) { { :year => 1999 } }
|
|
123
|
-
|
|
124
|
-
it 'returns a new date instance with the changed year' do
|
|
125
|
-
expect(date.change(changeset).year).to eq(1999)
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
describe 'when given a new precision' do
|
|
131
|
-
let(:changeset) { { :precision => :year } }
|
|
132
|
-
|
|
133
|
-
it 'returns a new date instance with the changed precision' do
|
|
134
|
-
expect(date.change(changeset).precision).to eq(:year)
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
it 'copies extended values by value' do
|
|
140
|
-
expect { date.change({}).approximate! }.not_to change { date.approximate? }
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
describe '#uncertain?' do
|
|
146
|
-
|
|
147
|
-
let(:date) { Date.new }
|
|
148
|
-
|
|
149
|
-
it { expect(Date.new).not_to be_uncertain }
|
|
150
|
-
|
|
151
|
-
[:year, :month, :day].each do |part|
|
|
152
|
-
it "should not be uncertain by default (#{part})" do
|
|
153
|
-
expect(Date.new.uncertain?(part)).to eq(false)
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
it "should be uncertain if set to uncertain (#{part})" do
|
|
157
|
-
date.uncertain.send("#{part}=", true)
|
|
158
|
-
expect(date.uncertain?(part)).to eq(true)
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
([:year, :month, :day] - [part]).each do |other|
|
|
162
|
-
it "#{other} should not be uncertain if #{part} is uncertain" do
|
|
163
|
-
date.uncertain.send("#{part}=", true)
|
|
164
|
-
expect(date.uncertain?(other)).to eq(false)
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
describe 'uncertain/approximate hash' do
|
|
173
|
-
|
|
174
|
-
it 'is 0 by default' do
|
|
175
|
-
expect(Date.new().send(:ua_hash)).to eq(0)
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
it 'is 8 for approximate year' do
|
|
179
|
-
expect(Date.new.approximate!(:year).send(:ua_hash)).to eq(8)
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
describe 'sorting and comparisons' do
|
|
185
|
-
let(:xmas) { Date.new(2011, 12, 24) }
|
|
186
|
-
let(:new_years_eve) { Date.new(2011, 12, 31) }
|
|
187
|
-
|
|
188
|
-
describe '#values' do
|
|
189
|
-
|
|
190
|
-
it 'returns [2011,12,24] for christmas' do
|
|
191
|
-
expect(xmas.values).to eq([2011,12,24])
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
it 'returns [2011,12] for christmas with month precision' do
|
|
195
|
-
expect(xmas.month_precision!.values).to eq([2011,12])
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
it 'returns [2011] for christmas with year precision' do
|
|
199
|
-
expect(xmas.year_precision!.values).to eq([2011])
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
describe '#<=>' do
|
|
205
|
-
|
|
206
|
-
it '2009-12-24 should be less than 2011-12-31' do
|
|
207
|
-
expect(Date.new(2009,12,24)).to be < Date.new(2011,12,31)
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
it '2009-12-24 should be less than 2011-12' do
|
|
211
|
-
expect(Date.new(2009,12,24)).to be < Date.edtf('2011-12')
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
it '2009-12-24 should be less than 2011' do
|
|
215
|
-
expect(Date.new(2009,12,24)).to be < Date.edtf('2011')
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
describe '#==' do
|
|
222
|
-
|
|
223
|
-
it "xmas and new year's eve are not equal" do
|
|
224
|
-
expect(xmas).not_to eq(new_years_eve)
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
it "xmas and new year's eve are equal using month percision" do
|
|
228
|
-
expect(xmas.month_precision!).to eq(new_years_eve.month_precision!)
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
it "xmas and january 24 are not equal using month percision" do
|
|
232
|
-
expect(xmas.month_precision!).not_to eq(xmas.month_precision!.next)
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
it "xmas and new year's eve are equal using year percision" do
|
|
237
|
-
expect(xmas.year_precision!).to eq(new_years_eve.year_precision!)
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
end
|
data/spec/edtf/epoch_spec.rb
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
module EDTF
|
|
4
|
-
|
|
5
|
-
describe Decade do
|
|
6
|
-
|
|
7
|
-
it { is_expected.not_to be nil }
|
|
8
|
-
|
|
9
|
-
describe '.current' do
|
|
10
|
-
it 'creates the current decade' do
|
|
11
|
-
expect(Decade.current.year).to eq((Time.now.year / 10) * 10)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
describe '#min' do
|
|
16
|
-
it 'the year 1990 should be the minimum of the 1990s' do
|
|
17
|
-
expect(Decade.new(1999).min).to eq(Date.new(1990).year_precision!)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
describe '#max' do
|
|
22
|
-
it 'the year 1999 should be the maximum of the 1990s' do
|
|
23
|
-
expect(Decade.new(1999).max).to eq(Date.new(1999).year_precision!)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it 'has year precision' do
|
|
27
|
-
expect(Decade.new(1999).max).to be_year_precision
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe '#cover?' do
|
|
32
|
-
it '1989-12-31 should be covered by the 1980s' do
|
|
33
|
-
expect(Decade.new(1980)).to be_cover(Date.new(1989,12,31))
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
describe '#to_range' do
|
|
38
|
-
|
|
39
|
-
it 'returns a range' do
|
|
40
|
-
expect(Decade.new.to_range).to be_instance_of(::Range)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it 'the range starts with a date object' do
|
|
44
|
-
expect(Decade.new.to_range.begin).to be_instance_of(::Date)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it 'the range ends with a date object' do
|
|
48
|
-
expect(Decade.new.to_range.end).to be_instance_of(::Date)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it 'the range start has year precision' do
|
|
52
|
-
expect(Decade.new.to_range.begin).to be_year_precision
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it 'the range end has year precision' do
|
|
56
|
-
expect(Decade.new.to_range.end).to be_year_precision
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe 'enumeration' do
|
|
62
|
-
|
|
63
|
-
it 'always covers ten years' do
|
|
64
|
-
expect(Decade.new.to_a.size).to eq(10)
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it 'the 1970s should map to the years [1970, 1971, ... , 1979]' do
|
|
68
|
-
expect(Decade.new(1970).map(&:year)).to eq([1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979])
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
describe Century do
|
|
76
|
-
|
|
77
|
-
it { is_expected.not_to be nil }
|
|
78
|
-
|
|
79
|
-
describe '.current' do
|
|
80
|
-
it 'creates the current century' do
|
|
81
|
-
expect(Century.current.year).to eq((Time.now.year / 100) * 100)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
end
|
data/spec/edtf/interval_spec.rb
DELETED
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
module EDTF
|
|
2
|
-
describe 'Interval' do
|
|
3
|
-
|
|
4
|
-
describe 'the interval 2008/2011' do
|
|
5
|
-
let(:interval) { Date.edtf('2008/2011') }
|
|
6
|
-
|
|
7
|
-
it { expect(interval).not_to be_open }
|
|
8
|
-
it { expect(interval).not_to be_open_end }
|
|
9
|
-
it { expect(interval).not_to be_unknown_start }
|
|
10
|
-
it { expect(interval).not_to be_unknown_end }
|
|
11
|
-
|
|
12
|
-
it 'has a length of 4' do
|
|
13
|
-
expect(interval.to_a.length).to eq(4)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it '#step(2) yields the years 2008 and 2010' do
|
|
17
|
-
expect(interval.step(2).map(&:year)).to eq([2008,2010])
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it 'the max date is 2011-12-31' do
|
|
21
|
-
expect(interval.max.to_s).to eq('2011-12-31')
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it 'the max date has year precision' do
|
|
25
|
-
expect(interval.max).to be_year_precision
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it 'the min date is 2008-01-01' do
|
|
29
|
-
expect(interval.min.to_s).to eq('2008-01-01')
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'the min date has year precision' do
|
|
33
|
-
expect(interval.min).to be_year_precision
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
it 'includes the years 2008, 2009, 2010 and 2011' do
|
|
38
|
-
expect(interval.to_a.map(&:year)).to eq([2008, 2009, 2010, 2011])
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it 'does not include christmas day 2009' do
|
|
42
|
-
expect(interval).not_to be_include(Date.new(2009,12,24))
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it 'christmas day 2009 is less than max' do
|
|
46
|
-
expect(Date.new(2009,12,24)).to be < interval.max
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it 'christmas day 2009 is greater than min' do
|
|
50
|
-
expect(Date.new(2009,12,24)).to be > interval.min
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it 'covers christmas day 2009' do
|
|
54
|
-
expect(interval).to be_cover(Date.new(2009,12,24))
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it 'covers 2011-12-31' do
|
|
58
|
-
expect(interval).to be_cover(Date.new(2011,12,31))
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
describe 'the interval 2008-08-23/2011-07-01' do
|
|
63
|
-
let(:interval) { Date.edtf('2008-08-23/2011-07-01') }
|
|
64
|
-
|
|
65
|
-
it 'includes christmas day 2009' do
|
|
66
|
-
expect(interval).to be_include(Date.new(2009,12,24))
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it 'covers christmas day 2009' do
|
|
70
|
-
expect(interval).to be_cover(Date.new(2009,12,24))
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it 'does not cover 2011-07-02' do
|
|
74
|
-
expect(interval).not_to be_cover(Date.new(2011,07,02))
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
describe 'the interval 2008-08-23/open' do
|
|
79
|
-
let(:interval) { Date.edtf('2008-08-23/open') }
|
|
80
|
-
|
|
81
|
-
it { expect(interval).to be_open }
|
|
82
|
-
it { expect(interval).to be_open_end }
|
|
83
|
-
it { expect(interval).not_to be_unknown }
|
|
84
|
-
it { expect(interval).not_to be_unknown_start }
|
|
85
|
-
it { expect(interval).not_to be_unknown_end }
|
|
86
|
-
|
|
87
|
-
it 'the min date is 2008-08-23' do
|
|
88
|
-
expect(interval.min).to eq(Date.new(2008,8,23))
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it 'the max date is nil' do
|
|
92
|
-
expect(interval.max).to be nil
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it 'includes christmas day 2009' do
|
|
96
|
-
expect(interval).to be_include(Date.new(2009,12,24))
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
it 'covers christmas day 2009' do
|
|
100
|
-
expect(interval).to be_cover(Date.new(2009,12,24))
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it 'covers 2023-07-02' do
|
|
104
|
-
expect(interval).to be_cover(Date.new(2023,07,02))
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
describe 'the interval 2008-08-23/..' do
|
|
110
|
-
let(:interval) { Date.edtf('2008-08-23/..') }
|
|
111
|
-
|
|
112
|
-
it { expect(interval).to be_open }
|
|
113
|
-
it { expect(interval).to be_open_end }
|
|
114
|
-
it { expect(interval).not_to be_unknown }
|
|
115
|
-
it { expect(interval).not_to be_unknown_start }
|
|
116
|
-
it { expect(interval).not_to be_unknown_end }
|
|
117
|
-
|
|
118
|
-
it 'the min date is 2008-08-23' do
|
|
119
|
-
expect(interval.min).to eq(Date.new(2008,8,23))
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
it 'the max date is nil' do
|
|
123
|
-
expect(interval.max).to be nil
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it 'includes christmas day 2009' do
|
|
127
|
-
expect(interval).to be_include(Date.new(2009,12,24))
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it 'covers christmas day 2009' do
|
|
131
|
-
expect(interval).to be_cover(Date.new(2009,12,24))
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
it 'covers 2023-07-02' do
|
|
135
|
-
expect(interval).to be_cover(Date.new(2023,07,02))
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
describe 'the interval open/2008-08-23' do
|
|
141
|
-
let(:interval) { Date.edtf('open/2008-08-23') }
|
|
142
|
-
|
|
143
|
-
it { expect(interval).to be_open }
|
|
144
|
-
it { expect(interval).to be_open_start }
|
|
145
|
-
it { expect(interval).not_to be_open_end }
|
|
146
|
-
it { expect(interval).not_to be_unknown }
|
|
147
|
-
it { expect(interval).not_to be_unknown_start }
|
|
148
|
-
it { expect(interval).not_to be_unknown_end }
|
|
149
|
-
|
|
150
|
-
it 'the max date is 2008-08-23' do
|
|
151
|
-
expect(interval.max).to eq(Date.new(2008,8,23))
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
it 'the min date is nil' do
|
|
155
|
-
expect(interval.min).to be nil
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
it 'includes christmas day 2007' do
|
|
159
|
-
expect(interval).to be_include(Date.new(2007,12,24))
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
it 'covers christmas day 2007' do
|
|
163
|
-
expect(interval).to be_cover(Date.new(2007,12,24))
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
it 'covers 2003-07-02' do
|
|
167
|
-
expect(interval).to be_cover(Date.new(2003,07,02))
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
describe 'the interval ../2008-08-23' do
|
|
172
|
-
let(:interval) { Date.edtf('../2008-08-23') }
|
|
173
|
-
|
|
174
|
-
it { expect(interval).to be_open }
|
|
175
|
-
it { expect(interval).to be_open_start }
|
|
176
|
-
it { expect(interval).not_to be_open_end }
|
|
177
|
-
it { expect(interval).not_to be_unknown }
|
|
178
|
-
it { expect(interval).not_to be_unknown_start }
|
|
179
|
-
it { expect(interval).not_to be_unknown_end }
|
|
180
|
-
|
|
181
|
-
it 'the max date is 2008-08-23' do
|
|
182
|
-
expect(interval.max).to eq(Date.new(2008,8,23))
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
it 'the min date is nil' do
|
|
186
|
-
expect(interval.min).to be nil
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
it 'includes christmas day 2007' do
|
|
190
|
-
expect(interval).to be_include(Date.new(2007,12,24))
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
it 'covers christmas day 2007' do
|
|
194
|
-
expect(interval).to be_cover(Date.new(2007,12,24))
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
it 'covers 2003-07-02' do
|
|
198
|
-
expect(interval).to be_cover(Date.new(2003,07,02))
|
|
199
|
-
end
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
describe 'the interval 2008/unknown' do
|
|
203
|
-
let(:interval) { Date.edtf('2008/unknown') }
|
|
204
|
-
|
|
205
|
-
it { expect(interval).to be_unknown }
|
|
206
|
-
it { expect(interval).to be_unknown_end }
|
|
207
|
-
it { expect(interval).not_to be_unknown_start }
|
|
208
|
-
|
|
209
|
-
it 'the min date is 2008-01-01' do
|
|
210
|
-
expect(interval.min.to_s).to eq('2008-01-01')
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
it 'the min date has year precision' do
|
|
214
|
-
expect(interval.min).to be_year_precision
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
it 'the max date is nil' do
|
|
218
|
-
expect(interval.max).to be nil
|
|
219
|
-
end
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
describe 'the interval unknown/2008' do
|
|
223
|
-
let(:interval) { Date.edtf('unknown/2008') }
|
|
224
|
-
|
|
225
|
-
it { expect(interval).to be_unknown }
|
|
226
|
-
it { expect(interval).not_to be_unknown_end }
|
|
227
|
-
it { expect(interval).to be_unknown_start }
|
|
228
|
-
|
|
229
|
-
it 'the max date is 2008-12-31' do
|
|
230
|
-
expect(interval.max.to_s).to eq('2008-12-31')
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
it 'the max date has year precision' do
|
|
234
|
-
expect(interval.max).to be_year_precision
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
it 'the min date is nil' do
|
|
238
|
-
expect(interval.min).to be nil
|
|
239
|
-
end
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
describe 'the interval 2008/' do
|
|
243
|
-
let(:interval) { Date.edtf('2008/') }
|
|
244
|
-
|
|
245
|
-
it { expect(interval).to be_unknown }
|
|
246
|
-
it { expect(interval).to be_unknown_end }
|
|
247
|
-
it { expect(interval).not_to be_unknown_start }
|
|
248
|
-
|
|
249
|
-
it 'the min date is 2008-01-01' do
|
|
250
|
-
expect(interval.min.to_s).to eq('2008-01-01')
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
it 'the min date has year precision' do
|
|
254
|
-
expect(interval.min).to be_year_precision
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
it 'the max date is nil' do
|
|
258
|
-
expect(interval.max).to be nil
|
|
259
|
-
end
|
|
260
|
-
end
|
|
261
|
-
|
|
262
|
-
describe 'the interval /2008' do
|
|
263
|
-
let(:interval) { Date.edtf('/2008') }
|
|
264
|
-
|
|
265
|
-
it { expect(interval).to be_unknown }
|
|
266
|
-
it { expect(interval).not_to be_unknown_end }
|
|
267
|
-
it { expect(interval).to be_unknown_start }
|
|
268
|
-
|
|
269
|
-
it 'the max date is 2008-12-31' do
|
|
270
|
-
expect(interval.max.to_s).to eq('2008-12-31')
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
it 'the max date has year precision' do
|
|
274
|
-
expect(interval.max).to be_year_precision
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
it 'the min date is nil' do
|
|
278
|
-
expect(interval.min).to be nil
|
|
279
|
-
end
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
describe 'comparisions' do
|
|
283
|
-
it '2007/2009 should be greater than 2001/2002' do
|
|
284
|
-
expect(Date.edtf('2007/2009')).to be > Date.edtf('2001/2002')
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
it '2007/2009 should be less than 2011/2012' do
|
|
288
|
-
expect(Date.edtf('2007/2009')).to be < Date.edtf('2011/2012')
|
|
289
|
-
end
|
|
290
|
-
|
|
291
|
-
it '2007/2009 should be less than 2008/2009' do
|
|
292
|
-
expect(Date.edtf('2007/2009')).to be < Date.edtf('2008/2009')
|
|
293
|
-
end
|
|
294
|
-
|
|
295
|
-
it '2007/2009 should be greater than 2007/2008' do
|
|
296
|
-
expect(Date.edtf('2007/2009')).to be > Date.edtf('2007/2008')
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
it '2007/2009 should be greater than 2006/2007' do
|
|
300
|
-
expect(Date.edtf('2007/2009')).to be > Date.edtf('2006/2007')
|
|
301
|
-
end
|
|
302
|
-
|
|
303
|
-
it '2007/2009 should be equal to 2007/2009' do
|
|
304
|
-
expect(Date.edtf('2007/2009')).to eq(Date.edtf('2007/2009'))
|
|
305
|
-
end
|
|
306
|
-
end
|
|
307
|
-
end
|
|
308
|
-
end
|