opening_hours_converter 1.7.2 → 1.7.3

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
2
  SHA1:
3
- metadata.gz: bce24802ab57a64088af5dc7a47f8e53d6519327
4
- data.tar.gz: 972e5ce2b13d003e67b28ac3fd3488ef03ba8345
3
+ metadata.gz: 2247a30906f6ff73bd768acc2470f298759acb30
4
+ data.tar.gz: 9603a200c0c5ab697ed36f2895c8d4c660f24a3f
5
5
  SHA512:
6
- metadata.gz: 266073e42c9902ef00136bb8b75946561602a6be1e1ad66994a7e1bc4a7739c515d0021579107ae4ca1dd16976af02b79518fb28c89da42af103783c095badc1
7
- data.tar.gz: fb3d198d80dad15a141491d1d09d6f19ba500495680c99d929ff4fe8fd157ae5c58b706df0fba82bce35ce5272384be1ed9fae00b4f7e4a85b0b851e3ed979b4
6
+ metadata.gz: 6ba007fcc7844a3870cd9b4a6a5ed4c59a677d9975e714e7e0133cb8a8a848d65fc79570bed8f9d290dc5ac82a4796463c0c1c7a7273c945de8b8801a97def17
7
+ data.tar.gz: 3010c805469d1a8ca0f907e84f47e6925139cf030efa2dcacc74b976d68cc445f0dc5744238fcc95b9bee68be41320216181cee8575cbbfef38331d47d75c46d
@@ -1,6 +1,5 @@
1
1
  require 'opening_hours_converter/constants'
2
2
  require 'json'
3
- require 'pry-byebug'
4
3
 
5
4
  module OpeningHoursConverter
6
5
  class OpeningHoursParser
@@ -473,6 +473,52 @@ module OpeningHoursConverter
473
473
  self_to_day.end[:month] == o_to_day.end[:month] &&
474
474
  self_to_day.end[:day] == o_to_day.end[:day])))
475
475
  end
476
+
477
+ def width
478
+ in_day = to_day
479
+ days_count = 0
480
+ if in_day.end
481
+ if in_day.start[:year]
482
+ if in_day.start[:year] != in_day.end[:year]
483
+ for year in in_day.start[:year]..in_day.end[:year]
484
+ if year == in_day.start[:year]
485
+ for month in in_day.start[:month]..12
486
+ if month == in_day.start[:month]
487
+ days_count += MONTH_END_DAY[month - 1] - in_day.start[:day]
488
+ else
489
+ days_count += MONTH_END_DAY[month - 1]
490
+ end
491
+ end
492
+ elsif year == in_day.end[:year]
493
+ for month in 1..in_day.end[:month]
494
+ if month == in_day.end[:month]
495
+ days_count += in_day.end[:day]
496
+ else
497
+ days_count += MONTH_END_DAY[month - 1]
498
+ end
499
+ end
500
+ else
501
+ for month in 1..12
502
+ days_count += MONTH_END_DAY[month - 1]
503
+ end
504
+ end
505
+ end
506
+ else
507
+ for month in in_day.start[:month]..in_day.end[:month]
508
+ days_count += MONTH_END_DAY[month - 1]
509
+ end
510
+ end
511
+ else
512
+ for month in in_day.start[:month]..in_day.end[:month]
513
+ days_count += MONTH_END_DAY[month - 1]
514
+ end
515
+ end
516
+ return days_count
517
+ else
518
+ return 1
519
+ end
520
+ end
521
+
476
522
  def to_day
477
523
  case @type
478
524
  when "day"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opening_hours_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ziserman Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-20 00:00:00.000000000 Z
11
+ date: 2017-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json