iso8601 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/iso8601/months.rb +1 -0
- data/lib/iso8601/version.rb +1 -1
- data/lib/iso8601/years.rb +2 -1
- data/spec/iso8601/months_spec.rb +0 -1
- data/spec/iso8601/time_interval_spec.rb +63 -52
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2b989c9cbc0ed939c15af4a776a7bc721069a8c0
|
4
|
+
data.tar.gz: b97d26d50d48493cb55c972acdefa9e7d851a4e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08f5b58f3345538a7b8ea1c871ded069fadc994098c0beaaeb43d0980ae3e2d68e0a094ab5d6b61c0b0935ce3ca597e713229622eec0b712bd0d5fdf73c145aa'
|
7
|
+
data.tar.gz: aabdc3c3a408a8f324fb1163b2199b0f7bbe73211b33bbb47a73f494f1bebfd1358067af0661ec555e601377244b47bf63610326ada0c9483caf5b5cb2f70275
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/iso8601/months.rb
CHANGED
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
|
data/spec/iso8601/months_spec.rb
CHANGED
@@ -128,17 +128,32 @@ RSpec.describe ISO8601::TimeInterval do
|
|
128
128
|
end
|
129
129
|
|
130
130
|
describe "#to_f" do
|
131
|
-
it "should calculate the size of time interval" do
|
131
|
+
it "should calculate the size of time interval <start>/<end>" do
|
132
132
|
hour = (60 * 60).to_f
|
133
|
-
|
134
|
-
pattern2 = '2010-05-09T11:30:
|
135
|
-
|
133
|
+
pattern1 = '2010-05-09T11:30:00Z/2010-05-09T12:30:00Z'
|
134
|
+
pattern2 = '2010-05-09T11:30:00+01:00/2010-05-09T12:30:00+01:00'
|
135
|
+
|
136
|
+
expect(ISO8601::TimeInterval.parse(pattern1).to_f).to eq(hour)
|
137
|
+
expect(ISO8601::TimeInterval.parse(pattern2).to_f).to eq(hour)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should calculate the size of time interval <start>/<duration>" do
|
141
|
+
hour = (60 * 60).to_f
|
142
|
+
pattern1 = '2010-05-09T11:30:00Z/PT1H'
|
143
|
+
pattern2 = '2010-05-09T11:30:00+01:00/PT1H'
|
136
144
|
|
137
|
-
expect(ISO8601::TimeInterval.parse(
|
145
|
+
expect(ISO8601::TimeInterval.parse(pattern1).to_f).to eq(hour)
|
138
146
|
expect(ISO8601::TimeInterval.parse(pattern2).to_f).to eq(hour)
|
139
|
-
expect(ISO8601::TimeInterval.parse(pattern3).to_f).to eq(hour)
|
140
147
|
end
|
141
148
|
|
149
|
+
it "should calculate the size of time interval <duration>/<end>" do
|
150
|
+
hour = (60 * 60).to_f
|
151
|
+
pattern1 = 'PT1H/2010-05-09T11:30:00Z'
|
152
|
+
pattern2 = 'PT1H/2010-05-09T11:30:00-09:00'
|
153
|
+
|
154
|
+
expect(ISO8601::TimeInterval.parse(pattern1).to_f).to eq(hour)
|
155
|
+
expect(ISO8601::TimeInterval.parse(pattern2).to_f).to eq(hour)
|
156
|
+
end
|
142
157
|
it "should be 0" do
|
143
158
|
expect(ISO8601::TimeInterval.parse('2015-01-01/2015-01-01').to_f).to eq(0)
|
144
159
|
end
|
@@ -175,14 +190,14 @@ RSpec.describe ISO8601::TimeInterval do
|
|
175
190
|
|
176
191
|
describe "November" do
|
177
192
|
pairs = [
|
178
|
-
{pattern: 'P1Y/2017-11-09T07:00:00Z',
|
179
|
-
|
180
|
-
{pattern: 'P1M/2017-11-09T07:00:00Z',
|
181
|
-
|
182
|
-
{pattern: 'P1D/2017-11-09T07:00:00Z',
|
183
|
-
|
184
|
-
{pattern: 'PT1H/2017-11-09T07:00:00Z',
|
185
|
-
|
193
|
+
{ pattern: 'P1Y/2017-11-09T07:00:00Z',
|
194
|
+
start_time: ISO8601::DateTime.new('2016-11-09T07:00:00Z') },
|
195
|
+
{ pattern: 'P1M/2017-11-09T07:00:00Z',
|
196
|
+
start_time: ISO8601::DateTime.new('2017-10-09T07:00:00Z') },
|
197
|
+
{ pattern: 'P1D/2017-11-09T07:00:00Z',
|
198
|
+
start_time: ISO8601::DateTime.new('2017-11-08T07:00:00Z') },
|
199
|
+
{ pattern: 'PT1H/2017-11-09T07:00:00Z',
|
200
|
+
start_time: ISO8601::DateTime.new('2017-11-09T06:00:00Z') }
|
186
201
|
]
|
187
202
|
|
188
203
|
pairs.each do |pair|
|
@@ -194,16 +209,16 @@ RSpec.describe ISO8601::TimeInterval do
|
|
194
209
|
|
195
210
|
describe "December" do
|
196
211
|
pairs = [
|
197
|
-
{pattern: 'P1Y/2017-12-09T07:00:00Z',
|
198
|
-
|
199
|
-
{pattern: 'P1M/2017-12-09T07:00:00Z',
|
200
|
-
|
201
|
-
{pattern: 'P3D/2017-12-06T18:30:00Z',
|
202
|
-
|
203
|
-
{pattern: 'P1D/2017-12-09T07:00:00Z',
|
204
|
-
|
205
|
-
{pattern: 'PT1H/2017-12-09T07:00:00Z',
|
206
|
-
|
212
|
+
{ pattern: 'P1Y/2017-12-09T07:00:00Z',
|
213
|
+
start_time: ISO8601::DateTime.new('2016-12-09T07:00:00Z') },
|
214
|
+
{ pattern: 'P1M/2017-12-09T07:00:00Z',
|
215
|
+
start_time: ISO8601::DateTime.new('2017-11-09T07:00:00Z') },
|
216
|
+
{ pattern: 'P3D/2017-12-06T18:30:00Z',
|
217
|
+
start_time: ISO8601::DateTime.new('2017-12-03T18:30:00Z') },
|
218
|
+
{ pattern: 'P1D/2017-12-09T07:00:00Z',
|
219
|
+
start_time: ISO8601::DateTime.new('2017-12-08T07:00:00Z') },
|
220
|
+
{ pattern: 'PT1H/2017-12-09T07:00:00Z',
|
221
|
+
start_time: ISO8601::DateTime.new('2017-12-09T06:00:00Z') }
|
207
222
|
]
|
208
223
|
|
209
224
|
pairs.each do |pair|
|
@@ -215,14 +230,14 @@ RSpec.describe ISO8601::TimeInterval do
|
|
215
230
|
|
216
231
|
describe "January" do
|
217
232
|
pairs = [
|
218
|
-
{pattern: 'P1Y/2017-01-01T00:00:00Z',
|
219
|
-
|
220
|
-
{pattern: 'P1M/2017-01-01T00:00:00Z',
|
221
|
-
|
222
|
-
{pattern: 'P1D/2017-01-01T00:00:00Z',
|
223
|
-
|
224
|
-
{pattern: 'PT1H/2017-01-01T01:00:00Z',
|
225
|
-
|
233
|
+
{ pattern: 'P1Y/2017-01-01T00:00:00Z',
|
234
|
+
start_time: ISO8601::DateTime.new('2016-01-01T00:00:00Z') },
|
235
|
+
{ pattern: 'P1M/2017-01-01T00:00:00Z',
|
236
|
+
start_time: ISO8601::DateTime.new('2016-12-01T00:00:00Z') },
|
237
|
+
{ pattern: 'P1D/2017-01-01T00:00:00Z',
|
238
|
+
start_time: ISO8601::DateTime.new('2016-12-31T00:00:00Z') },
|
239
|
+
{ pattern: 'PT1H/2017-01-01T01:00:00Z',
|
240
|
+
start_time: ISO8601::DateTime.new('2017-01-01T00:00:00Z') }
|
226
241
|
]
|
227
242
|
|
228
243
|
pairs.each do |pair|
|
@@ -234,14 +249,14 @@ RSpec.describe ISO8601::TimeInterval do
|
|
234
249
|
|
235
250
|
describe "February" do
|
236
251
|
pairs = [
|
237
|
-
{pattern: 'P1Y/2017-02-01T00:00:00Z',
|
238
|
-
|
239
|
-
{pattern: 'P1M/2017-02-01T00:00:00Z',
|
240
|
-
|
241
|
-
{pattern: 'P1D/2017-02-01T00:00:00Z',
|
242
|
-
|
243
|
-
{pattern: 'PT1H/2017-02-01T01:00:00Z',
|
244
|
-
|
252
|
+
{ pattern: 'P1Y/2017-02-01T00:00:00Z',
|
253
|
+
start_time: ISO8601::DateTime.new('2016-02-01T00:00:00Z') },
|
254
|
+
{ pattern: 'P1M/2017-02-01T00:00:00Z',
|
255
|
+
start_time: ISO8601::DateTime.new('2017-01-01T00:00:00Z') },
|
256
|
+
{ pattern: 'P1D/2017-02-01T00:00:00Z',
|
257
|
+
start_time: ISO8601::DateTime.new('2017-01-31T00:00:00Z') },
|
258
|
+
{ pattern: 'PT1H/2017-02-01T01:00:00Z',
|
259
|
+
start_time: ISO8601::DateTime.new('2017-02-01T00:00:00Z') }
|
245
260
|
]
|
246
261
|
|
247
262
|
pairs.each do |pair|
|
@@ -253,14 +268,14 @@ RSpec.describe ISO8601::TimeInterval do
|
|
253
268
|
|
254
269
|
describe "March" do
|
255
270
|
pairs = [
|
256
|
-
{pattern: 'P1Y/2017-03-01T00:00:00Z',
|
257
|
-
|
258
|
-
{pattern: 'P1M/2017-03-01T00:00:00Z',
|
259
|
-
|
260
|
-
{pattern: 'P1D/2017-03-01T00:00:00Z',
|
261
|
-
|
262
|
-
{pattern: 'PT1H/2017-03-01T01:00:00Z',
|
263
|
-
|
271
|
+
{ pattern: 'P1Y/2017-03-01T00:00:00Z',
|
272
|
+
start_time: ISO8601::DateTime.new('2016-03-01T00:00:00Z') },
|
273
|
+
{ pattern: 'P1M/2017-03-01T00:00:00Z',
|
274
|
+
start_time: ISO8601::DateTime.new('2017-02-01T00:00:00Z') },
|
275
|
+
{ pattern: 'P1D/2017-03-01T00:00:00Z',
|
276
|
+
start_time: ISO8601::DateTime.new('2017-02-28T00:00:00Z') },
|
277
|
+
{ pattern: 'PT1H/2017-03-01T01:00:00Z',
|
278
|
+
start_time: ISO8601::DateTime.new('2017-03-01T00:00:00Z') }
|
264
279
|
]
|
265
280
|
|
266
281
|
pairs.each do |pair|
|
@@ -269,10 +284,6 @@ RSpec.describe ISO8601::TimeInterval do
|
|
269
284
|
end
|
270
285
|
end
|
271
286
|
end
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
287
|
end
|
277
288
|
|
278
289
|
describe "#last" do
|
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.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arnau Siches
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project: iso8601
|
137
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.6.14
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Ruby parser to work with ISO 8601 dateTimes and durations - http://en.wikipedia.org/wiki/ISO_8601
|