opening_hours_converter 1.10.0 → 1.11.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/opening_hours_rule.rb +29 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d9c36ae7cf29f7c3cc90f3fa56a1b24f3294b9201356bb3c7cecf5319857343
|
4
|
+
data.tar.gz: 34079e2a3f1dbb735d5e07f9aab3a62d726cf0f7f88de29e86235a73462c5a4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68a659bdff345013b1c2e00df196725024792536e87b92b586c46e286f2bb8baab856d2c91564feb22c6d0969f26a1a5f781adf42e7d8f78659e3b1ef008e6e0
|
7
|
+
data.tar.gz: 8f977df19ce9fe13547f5215320b1a699ee1bf40a6b2e804865b9b9aba15e8dbe74eb5ac3c0f608f76010b6768b381c0f09fa537247be8fd31c78a611eb9a10a
|
@@ -172,23 +172,30 @@ module OpeningHoursConverter
|
|
172
172
|
else
|
173
173
|
result.each do |selector, intervals|
|
174
174
|
if selector == 'always'
|
175
|
-
intervals
|
175
|
+
if end_before_start?(intervals)
|
176
|
+
end_interval = intervals.select { |interval| interval[:start][:day] == 0 && interval[:start][:month] == 0 }.first
|
177
|
+
start_interval = intervals.select { |interval| interval[:end][:day] == 30 && interval[:end][:month] == 11 }.first
|
176
178
|
str_result += ',' if !str_result.empty?
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
179
|
+
str_result += "#{OSM_MONTHS[start_interval[:start][:month]]} #{start_interval[:start][:day] + 1 < 10 ? "0#{start_interval[:start][:day] + 1}" : start_interval[:start][:day] + 1}-#{OSM_MONTHS[end_interval[:end][:month]]} #{end_interval[:end][:day] + 1 < 10 ? "0#{end_interval[:end][:day] + 1}" : end_interval[:end][:day] + 1}"
|
180
|
+
else
|
181
|
+
intervals.each do |interval|
|
182
|
+
str_result += ',' if !str_result.empty?
|
183
|
+
if is_full_year?(interval)
|
184
|
+
elsif starts_year?(interval) && ends_year?(interval)
|
185
|
+
str_result += "#{interval[:start][:year]}-#{interval[:end][:year]}"
|
186
|
+
elsif is_full_month?(interval)
|
187
|
+
str_result += (OSM_MONTHS[interval[:start][:month]]).to_s
|
188
|
+
elsif is_same_month?(interval)
|
189
|
+
if is_same_day?(interval)
|
190
|
+
str_result += "#{OSM_MONTHS[interval[:start][:month]]} #{interval[:start][:day] + 1 < 10 ? "0#{interval[:start][:day] + 1}" : interval[:start][:day] + 1}"
|
191
|
+
else
|
192
|
+
str_result += "#{OSM_MONTHS[interval[:start][:month]]} #{interval[:start][:day] + 1 < 10 ? "0#{interval[:start][:day] + 1}" : interval[:start][:day] + 1}-#{interval[:end][:day] + 1 < 10 ? "0#{interval[:end][:day] + 1}" : interval[:end][:day] + 1}"
|
193
|
+
end
|
194
|
+
elsif starts_month?(interval) && ends_month?(interval)
|
195
|
+
str_result += "#{OSM_MONTHS[interval[:start][:month]]}-#{OSM_MONTHS[interval[:end][:month]]}"
|
185
196
|
else
|
186
|
-
str_result += "#{OSM_MONTHS[interval[:start][:month]]} #{interval[:start][:day] + 1 < 10 ? "0#{interval[:start][:day] + 1}" : interval[:start][:day] + 1}-#{interval[:end][:day] + 1 < 10 ? "0#{interval[:end][:day] + 1}" : interval[:end][:day] + 1}"
|
197
|
+
str_result += "#{OSM_MONTHS[interval[:start][:month]]} #{interval[:start][:day] + 1 < 10 ? "0#{interval[:start][:day] + 1}" : interval[:start][:day] + 1}-#{OSM_MONTHS[interval[:end][:month]]} #{interval[:end][:day] + 1 < 10 ? "0#{interval[:end][:day] + 1}" : interval[:end][:day] + 1}"
|
187
198
|
end
|
188
|
-
elsif starts_month?(interval) && ends_month?(interval)
|
189
|
-
str_result += "#{OSM_MONTHS[interval[:start][:month]]}-#{OSM_MONTHS[interval[:end][:month]]}"
|
190
|
-
else
|
191
|
-
str_result += "#{OSM_MONTHS[interval[:start][:month]]} #{interval[:start][:day] + 1 < 10 ? "0#{interval[:start][:day] + 1}" : interval[:start][:day] + 1}-#{OSM_MONTHS[interval[:end][:month]]} #{interval[:end][:day] + 1 < 10 ? "0#{interval[:end][:day] + 1}" : interval[:end][:day] + 1}"
|
192
199
|
end
|
193
200
|
end
|
194
201
|
elsif selector == 'multi_year'
|
@@ -225,7 +232,15 @@ module OpeningHoursConverter
|
|
225
232
|
str_result.strip
|
226
233
|
end
|
227
234
|
|
235
|
+
def end_before_start?(intervals)
|
236
|
+
intervals.length == 2 &&
|
237
|
+
intervals.one? { |interval| interval[:start][:day] == 0 && interval[:start][:month] == 0 } &&
|
238
|
+
intervals.one? { |interval| interval[:end][:day] == 30 && interval[:end][:month] == 11 }
|
239
|
+
end
|
240
|
+
|
228
241
|
def is_only_week_interval?(r)
|
242
|
+
return false if r == {}
|
243
|
+
|
229
244
|
r.all? do |year, intervals|
|
230
245
|
intervals.all? do |interval|
|
231
246
|
is_week_interval?(interval)
|
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.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ziserman Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|