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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 3c7b4ba1e602e306fa8bc033780f6a4f239aa2d592b4721f78e17dfc20bf61bc
4
- data.tar.gz: e7eeec472d8ed97d6ca44790b633c5ce881c26ae7363db7d6f786b7c8032b6e1
2
+ SHA1:
3
+ metadata.gz: 2b989c9cbc0ed939c15af4a776a7bc721069a8c0
4
+ data.tar.gz: b97d26d50d48493cb55c972acdefa9e7d851a4e4
5
5
  SHA512:
6
- metadata.gz: 6a2c878595f95c960deb2c70ea2a27adf74930545518147d3d0364ef23874a4efb54c5b6f640ef4df463994eed013afb78b3d7002b7796ef588873f966907cb6
7
- data.tar.gz: ea64e2bb8a9bebb77f8ad5d4611db9c72904e815abfd8047843b0dee1c5f4c6b9e95d081c23738f4098c80229774f707c598e61437e698c8f5b93f5d1448c9d1
6
+ metadata.gz: '08f5b58f3345538a7b8ea1c871ded069fadc994098c0beaaeb43d0980ae3e2d68e0a094ab5d6b61c0b0935ce3ca597e713229622eec0b712bd0d5fdf73c145aa'
7
+ data.tar.gz: aabdc3c3a408a8f324fb1163b2199b0f7bbe73211b33bbb47a73f494f1bebfd1358067af0661ec555e601377244b47bf63610326ada0c9483caf5b5cb2f70275
@@ -1,3 +1,7 @@
1
+ ## 0.10.1
2
+
3
+ * Fix `TimeInterval` size for non UTC timezones. (#41)
4
+
1
5
  ## 0.10.0
2
6
 
3
7
  * Fix `TimeInterval` with `<duration>/<end>` patterns and leap years.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- u ISO8601
1
+ # ISO8601
2
2
 
3
3
  Version 0.9.0 is **not compatible** with previous versions. Atoms and Durations
4
4
  changed their interface when treating base dates so it is only applied when
@@ -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
@@ -1,5 +1,5 @@
1
1
  module ISO8601
2
2
  ##
3
3
  # The gem version
4
- VERSION = '0.10.0'.freeze
4
+ VERSION = '0.10.1'.freeze
5
5
  end
@@ -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.utc(base.year + atom.to_i, base.month, base.day, base.hour, base.minute, base.second)
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
@@ -10,7 +10,6 @@ RSpec.describe ISO8601::Months do
10
10
  let(:common_december) { ISO8601::DateTime.new('2017-12-01') }
11
11
  let(:leap_december) { ISO8601::DateTime.new('2000-12-01') }
12
12
 
13
-
14
13
  describe 'Atomic' do
15
14
  let(:subject) { ISO8601::Months.new(1) }
16
15
 
@@ -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
- pattern = 'PT1H/2010-05-09T10:30:00Z'
134
- pattern2 = '2010-05-09T11:30:00Z/PT1H'
135
- pattern3 = '2010-05-09T11:30:00Z/2010-05-09T12:30:00Z'
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(pattern).to_f).to eq(hour)
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
- start_time: ISO8601::DateTime.new('2016-11-09T07:00:00Z')},
180
- {pattern: 'P1M/2017-11-09T07:00:00Z',
181
- start_time: ISO8601::DateTime.new('2017-10-09T07:00:00Z')},
182
- {pattern: 'P1D/2017-11-09T07:00:00Z',
183
- start_time: ISO8601::DateTime.new('2017-11-08T07:00:00Z')},
184
- {pattern: 'PT1H/2017-11-09T07:00:00Z',
185
- start_time: ISO8601::DateTime.new('2017-11-09T06:00:00Z')},
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
- start_time: ISO8601::DateTime.new('2016-12-09T07:00:00Z')},
199
- {pattern: 'P1M/2017-12-09T07:00:00Z',
200
- start_time: ISO8601::DateTime.new('2017-11-09T07:00:00Z')},
201
- {pattern: 'P3D/2017-12-06T18:30:00Z',
202
- start_time: ISO8601::DateTime.new('2017-12-03T18:30:00Z')},
203
- {pattern: 'P1D/2017-12-09T07:00:00Z',
204
- start_time: ISO8601::DateTime.new('2017-12-08T07:00:00Z')},
205
- {pattern: 'PT1H/2017-12-09T07:00:00Z',
206
- start_time: ISO8601::DateTime.new('2017-12-09T06:00:00Z')},
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
- start_time: ISO8601::DateTime.new('2016-01-01T00:00:00Z')},
220
- {pattern: 'P1M/2017-01-01T00:00:00Z',
221
- start_time: ISO8601::DateTime.new('2016-12-01T00:00:00Z')},
222
- {pattern: 'P1D/2017-01-01T00:00:00Z',
223
- start_time: ISO8601::DateTime.new('2016-12-31T00:00:00Z')},
224
- {pattern: 'PT1H/2017-01-01T01:00:00Z',
225
- start_time: ISO8601::DateTime.new('2017-01-01T00:00:00Z')},
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
- start_time: ISO8601::DateTime.new('2016-02-01T00:00:00Z')},
239
- {pattern: 'P1M/2017-02-01T00:00:00Z',
240
- start_time: ISO8601::DateTime.new('2017-01-01T00:00:00Z')},
241
- {pattern: 'P1D/2017-02-01T00:00:00Z',
242
- start_time: ISO8601::DateTime.new('2017-01-31T00:00:00Z')},
243
- {pattern: 'PT1H/2017-02-01T01:00:00Z',
244
- start_time: ISO8601::DateTime.new('2017-02-01T00:00:00Z')},
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
- start_time: ISO8601::DateTime.new('2016-03-01T00:00:00Z')},
258
- {pattern: 'P1M/2017-03-01T00:00:00Z',
259
- start_time: ISO8601::DateTime.new('2017-02-01T00:00:00Z')},
260
- {pattern: 'P1D/2017-03-01T00:00:00Z',
261
- start_time: ISO8601::DateTime.new('2017-02-28T00:00:00Z')},
262
- {pattern: 'PT1H/2017-03-01T01:00:00Z',
263
- start_time: ISO8601::DateTime.new('2017-03-01T00:00:00Z')},
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.0
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-09 00:00:00.000000000 Z
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.7.3
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