opening_hours_converter 1.6.5 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opening_hours_converter/wide_interval.rb +170 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dde0e88ef73e434363226fda08f86a3c90f64ff
|
4
|
+
data.tar.gz: e1dcb8effef3ea9ffad5034bf8783bede0fa40c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 870f6a0df3790e759e36c911542b4144f10a76503a22474299c3db448eac75f0abe3611edd276aa25e6d9764294b0f6b82ffe57376f787f127b8006393492559
|
7
|
+
data.tar.gz: dbb28223d2991e3e8cf7c94b986f483f40e56e20d15880539adb228a3e2764497bebd721239eee3d6ca01157ecc77d51b6d9387a8461987d0a51e0f8e2f4c61a
|
@@ -233,22 +233,189 @@ module OpeningHoursConverter
|
|
233
233
|
return result
|
234
234
|
end
|
235
235
|
|
236
|
-
def
|
236
|
+
def touch?(o)
|
237
|
+
return true if contains?(o)
|
238
|
+
return true if o.type == "always" || @type == "always"
|
239
|
+
result = false
|
240
|
+
if self.equals(o)
|
241
|
+
result = true
|
242
|
+
else
|
243
|
+
my = to_day
|
244
|
+
o = o.to_day
|
245
|
+
|
246
|
+
result = ((my_start_is_before_o_end?(my, o) && my_start_is_after_o_start?(my, o)) ||
|
247
|
+
(my_end_is_before_o_end?(my, o) && my_end_is_after_o_start?(my, o))) ||
|
248
|
+
((my_start_is_before_o_end?(o, my) && my_start_is_after_o_start?(o, my)) ||
|
249
|
+
(my_end_is_before_o_end?(o, my) && my_end_is_after_o_start?(o, my)))
|
250
|
+
end
|
251
|
+
return result
|
252
|
+
end
|
253
|
+
|
254
|
+
def my_start_is_after_o_start?(my, o)
|
237
255
|
result = false
|
238
256
|
if has_start_year?(o) && has_start_year?(my)
|
239
|
-
result = o.start[:year]
|
257
|
+
result = o.start[:year] < my.start[:year] || (o.start[:year] == my.start[:year] &&
|
258
|
+
my_start_day_is_after_o_start_day?(my, o))
|
240
259
|
elsif !has_start_year?(o) && !has_start_year?(my)
|
241
|
-
result =
|
260
|
+
result = my_start_day_is_after_o_start_day?(my, o)
|
261
|
+
end
|
262
|
+
result
|
263
|
+
end
|
264
|
+
|
265
|
+
def my_start_is_before_o_start?(my, o)
|
266
|
+
result = false
|
267
|
+
if has_start_year?(o) && has_start_year?(my)
|
268
|
+
result = o.start[:year] > my.start[:year] || (o.start[:year] == my.start[:year] &&
|
269
|
+
my_start_day_is_before_o_start_day?(my, o))
|
270
|
+
elsif !has_start_year?(o) && !has_start_year?(my)
|
271
|
+
result = my_start_day_is_before_o_start_day?(my, o)
|
242
272
|
end
|
243
273
|
result
|
244
274
|
end
|
245
275
|
|
276
|
+
def my_end_is_before_o_end?(my, o)
|
277
|
+
result = false
|
278
|
+
if !my.end.nil? && !o.end.nil?
|
279
|
+
if has_end_year?(o) && has_end_year?(my)
|
280
|
+
result = o.end[:year] > my.end[:year] || (o.end[:year] == my.end[:year] &&
|
281
|
+
my_end_day_is_before_o_end_day?(my, o))
|
282
|
+
elsif !has_end_year?(o) && !has_end_year?(my)
|
283
|
+
result = my_end_day_is_before_o_end_day?(my, o)
|
284
|
+
end
|
285
|
+
else
|
286
|
+
my_start_is_before_o_start?(my, o)
|
287
|
+
end
|
288
|
+
result
|
289
|
+
end
|
290
|
+
|
291
|
+
def my_start_is_before_o_end?(my, o)
|
292
|
+
result = false
|
293
|
+
if has_start_year?(o) && has_start_year?(my)
|
294
|
+
if o.end
|
295
|
+
result = o.end[:year] > my.start[:year] || (o.end[:year] == my.start[:year] &&
|
296
|
+
my_start_day_is_before_o_end_day?(my, o))
|
297
|
+
else
|
298
|
+
result = o.start[:year] > my.start[:year] || (o.start[:year] == my.start[:year] &&
|
299
|
+
my_start_day_is_before_o_end_day?(my, o))
|
300
|
+
end
|
301
|
+
elsif !has_start_year?(o) && !has_start_year?(my)
|
302
|
+
result = my_start_day_is_before_o_end_day?(my, o)
|
303
|
+
end
|
304
|
+
result
|
305
|
+
end
|
306
|
+
|
307
|
+
def my_end_is_after_o_start?(my, o)
|
308
|
+
result = false
|
309
|
+
if has_start_year?(o) && has_start_year?(my)
|
310
|
+
if my.end
|
311
|
+
result = o.start[:year] < my.end[:year] || (o.start[:year] == my.end[:year] &&
|
312
|
+
my_end_day_is_after_o_start_day?(my, o))
|
313
|
+
else
|
314
|
+
result = o.start[:year] < my.start[:year] || (o.start[:year] == my.start[:year] &&
|
315
|
+
my_end_day_is_after_o_start_day?(my, o))
|
316
|
+
end
|
317
|
+
elsif !has_start_year?(o) && !has_start_year?(my)
|
318
|
+
result = my_end_day_is_after_o_start_day?(my, o)
|
319
|
+
end
|
320
|
+
result
|
321
|
+
end
|
322
|
+
|
323
|
+
def my_start_day_is_after_o_start_day?(my, o)
|
324
|
+
(o.start[:month] < my.start[:month] ||
|
325
|
+
(o.start[:month] == my.start[:month] &&
|
326
|
+
o.start[:day] <= my.start[:day]))
|
327
|
+
end
|
328
|
+
|
329
|
+
def my_start_day_is_before_o_start_day?(my, o)
|
330
|
+
(o.start[:month] > my.start[:month] ||
|
331
|
+
(o.start[:month] == my.start[:month] &&
|
332
|
+
o.start[:day] >= my.start[:day]))
|
333
|
+
end
|
334
|
+
|
335
|
+
def my_start_day_is_before_o_end_day?(my, o)
|
336
|
+
if !o.end.nil?
|
337
|
+
(o.end[:month] > my.start[:month] ||
|
338
|
+
(o.end[:month] == my.start[:month] &&
|
339
|
+
o.end[:day] >= my.start[:day]))
|
340
|
+
else
|
341
|
+
(o.start[:month] > my.start[:month] ||
|
342
|
+
(o.start[:month] == my.start[:month] &&
|
343
|
+
o.start[:day] >= my.start[:day]))
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
def my_start_day_is_after_o_end_day?(my, o)
|
348
|
+
if !o.end.nil?
|
349
|
+
(o.end[:month] < my.start[:month] ||
|
350
|
+
(o.end[:month] == my.start[:month] &&
|
351
|
+
o.end[:day] <= my.start[:day]))
|
352
|
+
else
|
353
|
+
(o.start[:month] < my.start[:month] ||
|
354
|
+
(o.start[:month] == my.start[:month] &&
|
355
|
+
o.start[:day] <= my.start[:day]))
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
def my_end_day_is_before_o_end_day?(my, o)
|
360
|
+
if !o.end.nil? && !my.end.nil?
|
361
|
+
(o.end[:month] > my.end[:month] ||
|
362
|
+
(o.end[:month] == my.end[:month] &&
|
363
|
+
o.end[:day] >= my.end[:day]))
|
364
|
+
elsif o.end && my.end
|
365
|
+
(o.start[:month] > my.start[:month] ||
|
366
|
+
(o.start[:month] == my.start[:month] &&
|
367
|
+
o.start[:day] >= my.start[:day]))
|
368
|
+
elsif o.end
|
369
|
+
(o.end[:month] > my.start[:month] ||
|
370
|
+
(o.end[:month] == my.start[:month] &&
|
371
|
+
o.end[:day] >= my.start[:day]))
|
372
|
+
else
|
373
|
+
(o.start[:month] > my.end[:month] ||
|
374
|
+
(o.start[:month] == my.end[:month] &&
|
375
|
+
o.start[:day] >= my.end[:day]))
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
def my_end_day_is_after_o_start_day?(my, o)
|
380
|
+
if !o.end.nil?
|
381
|
+
(o.start[:month] < my.end[:month] ||
|
382
|
+
(o.start[:month] == my.end[:month] &&
|
383
|
+
o.start[:day] <= my.end[:day]))
|
384
|
+
else
|
385
|
+
(o.start[:month] < my.start[:month] ||
|
386
|
+
(o.start[:month] == my.start[:month] &&
|
387
|
+
o.start[:day] <= my.start[:day]))
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
def my_end_day_is_before_o_start_day?(my, o)
|
392
|
+
if !o.end.nil?
|
393
|
+
(o.start[:month] < my.end[:month] ||
|
394
|
+
(o.start[:month] == my.end[:month] &&
|
395
|
+
o.start[:day] <= my.end[:day]))
|
396
|
+
else
|
397
|
+
(o.start[:month] < my.start[:month] ||
|
398
|
+
(o.start[:month] == my.start[:month] &&
|
399
|
+
o.start[:day] <= my.start[:day]))
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
246
403
|
def has_superior_start_month?(my, o)
|
247
404
|
(o.start[:month] > my.start[:month] ||
|
248
405
|
(o.start[:month] == my.start[:month] &&
|
249
406
|
o.start[:day] >= my.start[:day]))
|
250
407
|
end
|
251
408
|
|
409
|
+
def has_superior_or_equal_start_day?(my, o)
|
410
|
+
result = false
|
411
|
+
if has_start_year?(o) && has_start_year?(my)
|
412
|
+
result = o.start[:year] > my.start[:year] || (o.start[:year] == my.start[:year] && has_superior_start_month?(my, o))
|
413
|
+
elsif !has_start_year?(o) && !has_start_year?(my)
|
414
|
+
result = has_superior_start_month?(my, o)
|
415
|
+
end
|
416
|
+
result
|
417
|
+
end
|
418
|
+
|
252
419
|
def has_inferior_or_equal_end_day?(my, o)
|
253
420
|
result = false
|
254
421
|
return false if my.end.nil?
|