opening_hours_converter 1.7.12 → 1.7.13

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: 5ab2dbbd4139cffd6168ebff0c58c44d7d281d6b
4
- data.tar.gz: ce505f3caa8ab41b7753b2442cd548962a9c3dd8
3
+ metadata.gz: 30b75efae1d2074a90198d343b7d48bd98e0b5b2
4
+ data.tar.gz: e54c64bfec49c98b6bf1efba450b8414e293866b
5
5
  SHA512:
6
- metadata.gz: cdfb270d1c926836fb87ca3e3eb547914742a92abcb3ac10049482593f3ec06e40d629e2a1bf8f88a641cd5c7da79943530cc284ec6478df06779e89b779718d
7
- data.tar.gz: 78a04fbf46aa03e66958f78cb0e815de6c1bc6b7bd0db5e1129508c3e7b944eec0fbba473bef3b153337817fb6aa6d3a902c54fab7f8ad75f9a77601f68c4b1a
6
+ metadata.gz: b37b12e0c001ef29dcf4bd301fc4421198b4909a209235a72c09c9b4f92b47fd540a1ab5a5a2da8339dd5da958123d4e670b2f61659bdd93985fecfcf0af7a97
7
+ data.tar.gz: 98e04d292316f92a63d7e56f782d6447b54ede78aab84c502b8785622e6a1c01bdee15048b1b4feca7016ccabc95a874538e9cb35c345497b7b93472e16d879e
@@ -10,7 +10,6 @@ module OpeningHoursConverter
10
10
 
11
11
  date_ranges.each do |date_range|
12
12
  years = OpeningHoursConverter::Year.build_day_array_from_date_range(date_range, true)
13
-
14
13
  result = []
15
14
 
16
15
  year_start = -1
@@ -70,6 +69,8 @@ module OpeningHoursConverter
70
69
  end
71
70
  date_ranges_array = get_iterator(date_ranges)
72
71
  datetime_result = []
72
+
73
+
73
74
  date_ranges_array.each_with_index do |result, index|
74
75
  result.each do |interval|
75
76
  (interval[:start]..interval[:end]).each do |day|
@@ -89,6 +90,7 @@ module OpeningHoursConverter
89
90
  end
90
91
  end
91
92
  end
93
+
92
94
  datetime_result.sort {|a,b| a[:start] <=> b[:start]}
93
95
 
94
96
  end
@@ -133,7 +135,6 @@ module OpeningHoursConverter
133
135
  def next_state(opening_hours_string, time=Time.now)
134
136
  date_ranges = OpeningHoursConverter::OpeningHoursParser.new.parse(opening_hours_string)
135
137
  ti = get_time_iterator(date_ranges)
136
-
137
138
  ti.each_with_index do |interval, index|
138
139
  return {end: interval[:end]} if interval[:start] <= time && interval[:end] >= time
139
140
  return {start: interval[:start]} if interval[:start] > time && ti[index-1][:end] <= time
@@ -11,14 +11,19 @@ module OpeningHoursConverter
11
11
  range_general = nil
12
12
  range_general_for = nil
13
13
  day_ph = false
14
+ off_day_ph = false
14
15
 
15
16
  date_ranges.each_with_index do |date_range, date_range_index|
16
17
  if !date_range.nil?
17
18
  if date_range.typical.intervals.length != 1
18
19
  date_range.typical.intervals.each_with_index do |interval, interval_id|
19
20
  if interval&.day_start == -2 && interval&.day_start == interval&.day_end
21
+ if interval.is_off
22
+ off_day_ph = true
23
+ else
24
+ day_ph = true
25
+ end
20
26
  date_range.typical.remove_interval(interval_id)
21
- day_ph = true
22
27
  end
23
28
  end
24
29
  end
@@ -52,6 +57,8 @@ module OpeningHoursConverter
52
57
  oh_rules = build_day(date_range)
53
58
  end
54
59
 
60
+
61
+
55
62
  oh_rules.each_with_index do |rule, i|
56
63
  oh_rules[i].add_comment(date_range.comment)
57
64
  end
@@ -90,6 +97,10 @@ module OpeningHoursConverter
90
97
  oh_rule.add_ph_weekday
91
98
  end
92
99
 
100
+ if off_day_ph
101
+ rules += build_off_holiday(date_range)
102
+ end
103
+
93
104
  if !oh_rule_added
94
105
  rules << oh_rule
95
106
  end
@@ -125,6 +136,21 @@ module OpeningHoursConverter
125
136
  return result.strip
126
137
  end
127
138
 
139
+ def build_off_holiday(date_range)
140
+
141
+ start_year = date_range.wide_interval.start&.key?(:year) ? date_range.wide_interval.start[:year] : date_range.wide_interval.start
142
+ end_year = date_range.wide_interval.end&.key?(:year) ? date_range.wide_interval.end[:year] : date_range.wide_interval.end
143
+
144
+ date_range = OpeningHoursConverter::DateRange.new(OpeningHoursConverter::WideInterval.new.holiday("PH", start_year, end_year))
145
+
146
+ rule = OpeningHoursConverter::OpeningHoursRule.new
147
+ date = OpeningHoursConverter::OpeningHoursDate.new(date_range.wide_interval, date_range.wide_interval.type, [-1])
148
+ rule.add_date(date)
149
+ rule.is_defined_off = true
150
+
151
+ return [ rule ]
152
+ end
153
+
128
154
  def build_holiday(date_range)
129
155
 
130
156
  start_year = date_range.wide_interval.start&.key?(:year) ? date_range.wide_interval.start[:year] : date_range.wide_interval.start
@@ -254,7 +254,7 @@ module OpeningHoursConverter
254
254
  end
255
255
 
256
256
  def same_time?(o)
257
- if o.nil? || o.time.length != @time.length
257
+ if o.nil? || o.time.length != @time.length || @is_defined_off != o.is_defined_off
258
258
  return false
259
259
  else
260
260
  @time.each_with_index do |t, i|
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.12
4
+ version: 1.7.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ziserman Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-15 00:00:00.000000000 Z
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json