opening_hours_converter 1.8.0 → 1.8.1
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/constants.rb +7 -7
- data/lib/opening_hours_converter/interval.rb +1 -1
- data/lib/opening_hours_converter/iterator.rb +36 -46
- data/lib/opening_hours_converter/opening_hours_builder.rb +128 -161
- data/lib/opening_hours_converter/opening_hours_date.rb +52 -57
- data/lib/opening_hours_converter/opening_hours_parser.rb +114 -137
- data/lib/opening_hours_converter/opening_hours_rule.rb +69 -85
- data/lib/opening_hours_converter/opening_hours_time.rb +7 -9
- data/lib/opening_hours_converter/public_holiday.rb +19 -19
- data/lib/opening_hours_converter/week.rb +36 -44
- data/lib/opening_hours_converter/wide_interval.rb +145 -160
- metadata +2 -2
@@ -12,46 +12,44 @@ module OpeningHoursConverter
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def get_time_selector
|
15
|
-
result =
|
15
|
+
result = ''
|
16
16
|
|
17
17
|
case @type
|
18
|
-
when
|
19
|
-
result = "#{@start[:year].nil? ?
|
18
|
+
when 'day'
|
19
|
+
result = "#{@start[:year].nil? ? '' : "#{@start[:year]} "}#{OSM_MONTHS[@start[:month] - 1]} #{@start[:day] < 10 ? '0' : ''}#{@start[:day]}"
|
20
20
|
if !@end.nil?
|
21
21
|
if @start[:month] == @end[:month]
|
22
|
-
result += "-#{@start[:year] == @end[:year] ?
|
22
|
+
result += "-#{@start[:year] == @end[:year] ? '' : "#{@end[:year]} "}#{@end[:day] < 10 ? '0' : ''}#{@end[:day]}"
|
23
23
|
else
|
24
|
-
result += "-#{@start[:year] == @end[:year] ?
|
24
|
+
result += "-#{@start[:year] == @end[:year] ? '' : "#{@end[:year]} "}#{OSM_MONTHS[@end[:month] - 1]} #{@end[:day] < 10 ? '0' : ''}#{@end[:day]}"
|
25
25
|
end
|
26
26
|
end
|
27
|
-
when
|
28
|
-
result = "#{@start[:year].nil? ?
|
27
|
+
when 'month'
|
28
|
+
result = "#{@start[:year].nil? ? '' : "#{@start[:year]} "}#{OSM_MONTHS[@start[:month] - 1]}"
|
29
29
|
if !@end.nil?
|
30
|
-
result += "-#{@start[:year] == @end[:year] ?
|
30
|
+
result += "-#{@start[:year] == @end[:year] ? '' : "#{@end[:year]} "}#{OSM_MONTHS[@end[:month] - 1]}"
|
31
31
|
end
|
32
|
-
when
|
33
|
-
result =
|
32
|
+
when 'year'
|
33
|
+
result = (@start[:year]).to_s
|
34
|
+
result += "-#{@end[:year]}" if !@end.nil?
|
35
|
+
when 'holiday'
|
36
|
+
result = "#{@start[:year].nil? ? '' : "#{@start[:year]} "}PH"
|
34
37
|
if !@end.nil?
|
35
|
-
result
|
38
|
+
result = "#{@start[:year]}#{@start[:year] == @end[:year] ? '' : "-#{@end[:year]}"} PH"
|
36
39
|
end
|
37
|
-
when
|
38
|
-
result =
|
39
|
-
if !@end.nil?
|
40
|
-
result = "#{@start[:year]}#{@start[:year] == @end[:year] ? "" : "-#{@end[:year]}"} PH"
|
41
|
-
end
|
42
|
-
when "always"
|
43
|
-
result = ""
|
40
|
+
when 'always'
|
41
|
+
result = ''
|
44
42
|
else
|
45
|
-
result =
|
43
|
+
result = ''
|
46
44
|
end
|
47
45
|
result
|
48
46
|
end
|
49
47
|
|
50
48
|
def get_time_for_humans
|
51
|
-
result =
|
49
|
+
result = ''
|
52
50
|
|
53
51
|
case @type
|
54
|
-
when
|
52
|
+
when 'day'
|
55
53
|
if !@end.nil?
|
56
54
|
if @start[:year] && !@end[:year] || @start[:year] && @start[:year] == @end[:year]
|
57
55
|
result = "du #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} au #{@end[:day]} #{IRL_MONTHS[@end[:month] - 1]} #{@start[:year]}"
|
@@ -63,9 +61,9 @@ module OpeningHoursConverter
|
|
63
61
|
result = "le #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]}"
|
64
62
|
end
|
65
63
|
else
|
66
|
-
result = "le #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]
|
64
|
+
result = "le #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year] || ''}"
|
67
65
|
end
|
68
|
-
when
|
66
|
+
when 'month'
|
69
67
|
if !@end.nil?
|
70
68
|
if @start[:year] && !@end[:year] || @start[:year] && @start[:year] == @end[:year]
|
71
69
|
result = "de #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} à #{IRL_MONTHS[@end[:month] - 1]} #{@start[:year]}"
|
@@ -75,169 +73,155 @@ module OpeningHoursConverter
|
|
75
73
|
result = "de #{IRL_MONTHS[@start[:month] - 1]} à #{IRL_MONTHS[@end[:month] - 1]}"
|
76
74
|
end
|
77
75
|
else
|
78
|
-
result = "#{IRL_MONTHS[@start[:month] - 1]}#{@start[:year] ? " #{@start[:year]}" :
|
79
|
-
end
|
80
|
-
when "year"
|
81
|
-
if !@end.nil?
|
82
|
-
result = "de #{@start[:year]} à #{@end[:year]}"
|
83
|
-
else
|
84
|
-
result = "#{@start[:year]}"
|
85
|
-
end
|
86
|
-
when "holiday"
|
87
|
-
if !@end.nil?
|
88
|
-
if !@start[:year]
|
89
|
-
result = "jours fériés"
|
90
|
-
else
|
91
|
-
result = "les jours fériés de #{@start[:year]} à #{@end[:year]}"
|
92
|
-
end
|
93
|
-
else
|
94
|
-
if !@start[:year]
|
95
|
-
result = "jours fériés"
|
96
|
-
else
|
97
|
-
result = "les jours fériés de #{@start[:year]}"
|
98
|
-
end
|
76
|
+
result = "#{IRL_MONTHS[@start[:month] - 1]}#{@start[:year] ? " #{@start[:year]}" : ''}"
|
99
77
|
end
|
100
|
-
when
|
101
|
-
result =
|
78
|
+
when 'year'
|
79
|
+
result = if !@end.nil?
|
80
|
+
"de #{@start[:year]} à #{@end[:year]}"
|
81
|
+
else
|
82
|
+
(@start[:year]).to_s
|
83
|
+
end
|
84
|
+
when 'holiday'
|
85
|
+
result = if !@end.nil?
|
86
|
+
if !@start[:year]
|
87
|
+
'jours fériés'
|
88
|
+
else
|
89
|
+
"les jours fériés de #{@start[:year]} à #{@end[:year]}"
|
90
|
+
end
|
91
|
+
else
|
92
|
+
if !@start[:year]
|
93
|
+
'jours fériés'
|
94
|
+
else
|
95
|
+
"les jours fériés de #{@start[:year]}"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
when 'always'
|
99
|
+
result = 'tout le temps'
|
102
100
|
end
|
103
|
-
|
101
|
+
result
|
104
102
|
end
|
105
103
|
|
106
|
-
def day(start_day, start_month, start_year=nil, end_day=nil, end_month=nil, end_year=nil)
|
104
|
+
def day(start_day, start_month, start_year = nil, end_day = nil, end_month = nil, end_year = nil)
|
107
105
|
if start_day.nil? || start_month.nil?
|
108
|
-
raise(ArgumentError,
|
106
|
+
raise(ArgumentError, 'start_day, start_month and start_year are required')
|
109
107
|
end
|
110
108
|
@start = { day: start_day, month: start_month, year: start_year }
|
111
|
-
if
|
109
|
+
if !end_day.nil? && !end_month.nil? && (end_day != start_day || end_month != start_month || (!start_year.nil? && !end_year.nil? && end_year != start_year))
|
112
110
|
@end = { day: end_day, month: end_month, year: end_year }
|
113
111
|
end
|
114
|
-
@type =
|
112
|
+
@type = 'day'
|
115
113
|
self
|
116
114
|
end
|
117
115
|
|
118
|
-
def date_time(start_date, end_date=nil)
|
119
|
-
if start_date.nil?
|
120
|
-
|
121
|
-
|
122
|
-
if !start_date.instance_of?(DateTime)
|
123
|
-
raise(ArgumentError, "start_date is not a DateTime")
|
124
|
-
end
|
125
|
-
if !end_date.instance_of?(DateTime)
|
126
|
-
raise(ArgumentError, "end_date is not a DateTime")
|
127
|
-
end
|
116
|
+
def date_time(start_date, end_date = nil)
|
117
|
+
raise(ArgumentError, 'start_date is required') if start_date.nil?
|
118
|
+
raise(ArgumentError, 'start_date is not a DateTime') if !start_date.instance_of?(DateTime)
|
119
|
+
raise(ArgumentError, 'end_date is not a DateTime') if !end_date.instance_of?(DateTime)
|
128
120
|
@start = { day: start_date.day, month: start_date.month, year: start_date.year }
|
129
121
|
if !end_date.nil? && end_date != start_date
|
130
122
|
@end = { day: end_date.day, month: end_date.month, year: end_date.year }
|
131
123
|
end
|
132
|
-
@type =
|
124
|
+
@type = 'day'
|
133
125
|
self
|
134
126
|
end
|
135
127
|
|
136
|
-
def month(start_month, start_year=nil, end_month=nil, end_year=nil)
|
137
|
-
if start_month.nil?
|
138
|
-
raise(ArgumentError, "start_month is required")
|
139
|
-
end
|
128
|
+
def month(start_month, start_year = nil, end_month = nil, end_year = nil)
|
129
|
+
raise(ArgumentError, 'start_month is required') if start_month.nil?
|
140
130
|
@start = { month: start_month, year: start_year }
|
141
131
|
if !end_month.nil? && (end_month != start_month || (!start_year.nil? && !end_year.nil? && end_year != start_year))
|
142
132
|
@end = { month: end_month, year: end_year }
|
143
133
|
end
|
144
|
-
@type =
|
134
|
+
@type = 'month'
|
145
135
|
self
|
146
136
|
end
|
147
137
|
|
148
|
-
def year(start_year, end_year=nil)
|
149
|
-
if start_year.nil?
|
150
|
-
raise(ArgumentError, "start_year is required")
|
151
|
-
end
|
138
|
+
def year(start_year, end_year = nil)
|
139
|
+
raise(ArgumentError, 'start_year is required') if start_year.nil?
|
152
140
|
@start = { year: start_year }
|
153
|
-
unless end_year.nil? || end_year == start_year
|
154
|
-
|
155
|
-
end
|
156
|
-
@type = "year"
|
141
|
+
@end = { year: end_year } unless end_year.nil? || end_year == start_year
|
142
|
+
@type = 'year'
|
157
143
|
self
|
158
144
|
end
|
159
145
|
|
160
|
-
def holiday(holiday, start_year=nil, end_year=nil)
|
161
|
-
if holiday.nil? || holiday !=
|
162
|
-
raise(ArgumentError,
|
146
|
+
def holiday(holiday, start_year = nil, end_year = nil)
|
147
|
+
if holiday.nil? || holiday != 'PH'
|
148
|
+
raise(ArgumentError, 'holiday is required and can only be PH')
|
163
149
|
end
|
164
150
|
@start = { holiday: holiday, year: start_year }
|
165
|
-
unless end_year.nil? || end_year == start_year
|
166
|
-
|
167
|
-
end
|
168
|
-
@type = "holiday"
|
151
|
+
@end = { holiday: holiday, year: end_year } unless end_year.nil? || end_year == start_year
|
152
|
+
@type = 'holiday'
|
169
153
|
self
|
170
154
|
end
|
171
155
|
|
172
156
|
def always
|
173
157
|
@start = nil
|
174
158
|
@end = nil
|
175
|
-
@type =
|
159
|
+
@type = 'always'
|
176
160
|
self
|
177
161
|
end
|
178
162
|
|
179
163
|
def is_full_month?
|
180
|
-
return true if @type ==
|
164
|
+
return true if @type == 'month' && @end.nil?
|
181
165
|
return false if @end.nil?
|
182
166
|
return false if !@start[:year].nil? && !@end[:year].nil? && @start[:year] != @end[:year]
|
183
|
-
if @type ==
|
167
|
+
if @type == 'day'
|
184
168
|
@start[:day] == 1 && !@end.nil? && @start[:month] == @end[:month] &&
|
185
|
-
|
169
|
+
!@end[:day].nil? && @end[:day] == MONTH_END_DAY[@end[:month] - 1]
|
186
170
|
else
|
187
171
|
false
|
188
172
|
end
|
189
173
|
end
|
190
174
|
|
191
175
|
def starts_month?
|
192
|
-
@type ==
|
176
|
+
@type == 'month' || @type == 'always' || @type == 'year' || (@type == 'day' && @start[:day] == 1)
|
193
177
|
end
|
194
178
|
|
195
179
|
def ends_month?
|
196
|
-
@type ==
|
180
|
+
@type == 'month' || @type == 'always' || @type == 'year' || (@type == 'day' && !@end.nil? && @end[:day] == MONTH_END_DAY[@end[:month] - 1])
|
197
181
|
end
|
198
182
|
|
199
183
|
def is_full_year?
|
200
|
-
return true if @end.nil? && type ==
|
184
|
+
return true if @end.nil? && type == 'year'
|
201
185
|
return false if @end.nil?
|
202
186
|
return false if !@start[:year].nil? && !@end[:year].nil? && @start[:year] != @end[:year]
|
203
|
-
if @type ==
|
187
|
+
if @type == 'month'
|
204
188
|
@start[:month] == 1 && !@end.nil? && @start[:year] == @end[:year] && !@end[:month].nil? && @end[:month] == 12
|
205
|
-
elsif @type ==
|
189
|
+
elsif @type == 'day'
|
206
190
|
@start[:day] == 1 && @start[:month] == 1 && !@end.nil? && !@start[:year].nil? && !@end[:year].nil? && @start[:year] == @end[:year] &&
|
207
|
-
|
191
|
+
!@end[:month].nil? && @end[:month] == 12 && !@end[:day].nil? && @end[:day] == MONTH_END_DAY[@end[:month] - 1]
|
208
192
|
else
|
209
193
|
false
|
210
194
|
end
|
211
195
|
end
|
212
196
|
|
213
197
|
def starts_year?
|
214
|
-
@type ==
|
198
|
+
@type == 'year' || @type == 'always' || (@type == 'day' && @start[:day] == 1 && @start[:month] == 1) || (@type == 'month' && @start[:month] == 1)
|
215
199
|
end
|
216
200
|
|
217
201
|
def ends_year?
|
218
|
-
@type ==
|
202
|
+
@type == 'year' || @type == 'always' || (@type == 'day' && !@end.nil? && @end[:month] == 12 && @end[:day] == MONTH_END_DAY[@end[:month] - 1])
|
219
203
|
end
|
220
204
|
|
221
205
|
def contains?(o)
|
222
|
-
return false if o.type ==
|
206
|
+
return false if o.type == 'always'
|
223
207
|
result = false
|
224
|
-
if
|
208
|
+
if equals(o)
|
225
209
|
result = false
|
226
|
-
elsif @type ==
|
210
|
+
elsif @type == 'always'
|
227
211
|
result = true
|
228
212
|
else
|
229
213
|
my = to_day
|
230
214
|
o = o.to_day
|
231
215
|
result = has_superior_or_equal_start_day?(my, o) && has_inferior_or_equal_end_day?(my, o)
|
232
216
|
end
|
233
|
-
|
217
|
+
result
|
234
218
|
end
|
235
219
|
|
236
220
|
def touch?(o)
|
237
221
|
return true if contains?(o)
|
238
|
-
return true if o.type ==
|
222
|
+
return true if o.type == 'always' || @type == 'always'
|
239
223
|
result = false
|
240
|
-
if
|
224
|
+
if equals(o)
|
241
225
|
result = true
|
242
226
|
else
|
243
227
|
my = to_day
|
@@ -245,10 +229,10 @@ module OpeningHoursConverter
|
|
245
229
|
|
246
230
|
result = ((my_start_is_before_o_end?(my, o) && my_start_is_after_o_start?(my, o)) ||
|
247
231
|
(my_end_is_before_o_end?(my, o) && my_end_is_after_o_start?(my, o))) ||
|
248
|
-
|
249
|
-
|
232
|
+
((my_start_is_before_o_end?(o, my) && my_start_is_after_o_start?(o, my)) ||
|
233
|
+
(my_end_is_before_o_end?(o, my) && my_end_is_after_o_start?(o, my)))
|
250
234
|
end
|
251
|
-
|
235
|
+
result
|
252
236
|
end
|
253
237
|
|
254
238
|
def my_start_is_after_o_start?(my, o)
|
@@ -291,13 +275,13 @@ module OpeningHoursConverter
|
|
291
275
|
def my_start_is_before_o_end?(my, o)
|
292
276
|
result = false
|
293
277
|
if has_start_year?(o) && has_start_year?(my)
|
294
|
-
if o.end
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
278
|
+
result = if o.end
|
279
|
+
o.end[:year] > my.start[:year] || (o.end[:year] == my.start[:year] &&
|
280
|
+
my_start_day_is_before_o_end_day?(my, o))
|
281
|
+
else
|
282
|
+
o.start[:year] > my.start[:year] || (o.start[:year] == my.start[:year] &&
|
283
|
+
my_start_day_is_before_o_end_day?(my, o))
|
284
|
+
end
|
301
285
|
elsif !has_start_year?(o) && !has_start_year?(my)
|
302
286
|
result = my_start_day_is_before_o_end_day?(my, o)
|
303
287
|
end
|
@@ -307,13 +291,13 @@ module OpeningHoursConverter
|
|
307
291
|
def my_end_is_after_o_start?(my, o)
|
308
292
|
result = false
|
309
293
|
if has_start_year?(o) && has_start_year?(my)
|
310
|
-
if my.end
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
294
|
+
result = if my.end
|
295
|
+
o.start[:year] < my.end[:year] || (o.start[:year] == my.end[:year] &&
|
296
|
+
my_end_day_is_after_o_start_day?(my, o))
|
297
|
+
else
|
298
|
+
o.start[:year] < my.start[:year] || (o.start[:year] == my.start[:year] &&
|
299
|
+
my_end_day_is_after_o_start_day?(my, o))
|
300
|
+
end
|
317
301
|
elsif !has_start_year?(o) && !has_start_year?(my)
|
318
302
|
result = my_end_day_is_after_o_start_day?(my, o)
|
319
303
|
end
|
@@ -451,21 +435,22 @@ module OpeningHoursConverter
|
|
451
435
|
def has_start_year?(date)
|
452
436
|
!date.start[:year].nil?
|
453
437
|
end
|
438
|
+
|
454
439
|
def has_end_year?(date)
|
455
440
|
!date.end[:year].nil?
|
456
441
|
end
|
457
442
|
|
458
443
|
def equals(o)
|
459
444
|
return false unless o.instance_of?(OpeningHoursConverter::WideInterval)
|
460
|
-
return @type ==
|
461
|
-
if @type ==
|
462
|
-
return (o.type ==
|
445
|
+
return @type == 'always' if o.type == 'always'
|
446
|
+
if @type == 'holiday'
|
447
|
+
return (o.type == 'holiday' && (@start[:year] == o.start[:year]) &&
|
463
448
|
(@end.nil? && o.end.nil? || (@end && o.end && @end[:year] == o.end[:year])))
|
464
449
|
end
|
465
|
-
return false if @type ==
|
450
|
+
return false if @type == 'always'
|
466
451
|
self_to_day = to_day
|
467
452
|
o_to_day = o.to_day
|
468
|
-
|
453
|
+
(self_to_day.start[:year] == o_to_day.start[:year] &&
|
469
454
|
self_to_day.start[:month] == o_to_day.start[:month] &&
|
470
455
|
self_to_day.start[:day] == o_to_day.start[:day]) &&
|
471
456
|
((self_to_day.end.nil? && o_to_day.end.nil?) || ((!self_to_day.end.nil? && !o_to_day.end.nil?) &&
|
@@ -475,7 +460,7 @@ module OpeningHoursConverter
|
|
475
460
|
end
|
476
461
|
|
477
462
|
def width
|
478
|
-
return Float::INFINITY if @type ==
|
463
|
+
return Float::INFINITY if @type == 'always'
|
479
464
|
in_day = to_day
|
480
465
|
days_count = 0
|
481
466
|
if in_day.end
|
@@ -484,19 +469,19 @@ module OpeningHoursConverter
|
|
484
469
|
for year in in_day.start[:year]..in_day.end[:year]
|
485
470
|
if year == in_day.start[:year]
|
486
471
|
for month in in_day.start[:month]..12
|
487
|
-
if month == in_day.start[:month]
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
472
|
+
days_count += if month == in_day.start[:month]
|
473
|
+
MONTH_END_DAY[month - 1] - in_day.start[:day] + 1
|
474
|
+
else
|
475
|
+
MONTH_END_DAY[month - 1]
|
476
|
+
end
|
492
477
|
end
|
493
478
|
elsif year == in_day.end[:year]
|
494
479
|
for month in 1..in_day.end[:month]
|
495
|
-
if month == in_day.end[:month]
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
480
|
+
days_count += if month == in_day.end[:month]
|
481
|
+
in_day.end[:day]
|
482
|
+
else
|
483
|
+
MONTH_END_DAY[month - 1]
|
484
|
+
end
|
500
485
|
end
|
501
486
|
else
|
502
487
|
for month in 1..12
|
@@ -509,13 +494,13 @@ module OpeningHoursConverter
|
|
509
494
|
days_count += in_day.end[:day] - in_day.start[:day] + 1
|
510
495
|
else
|
511
496
|
for month in in_day.start[:month]..in_day.end[:month]
|
512
|
-
if month == in_day.end[:month]
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
497
|
+
days_count += if month == in_day.end[:month]
|
498
|
+
in_day.end[:day]
|
499
|
+
elsif month == in_day.start[:month]
|
500
|
+
MONTH_END_DAY[month - 1] - in_day.start[:day] + 1
|
501
|
+
else
|
502
|
+
MONTH_END_DAY[month - 1]
|
503
|
+
end
|
519
504
|
end
|
520
505
|
end
|
521
506
|
end
|
@@ -524,28 +509,28 @@ module OpeningHoursConverter
|
|
524
509
|
days_count += in_day.end[:day] - in_day.start[:day] + 1
|
525
510
|
elsif in_day.start[:month] > in_day.end[:month]
|
526
511
|
for month in in_day.start[:month]..12
|
527
|
-
if month == in_day.start[:month]
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
512
|
+
days_count += if month == in_day.start[:month]
|
513
|
+
MONTH_END_DAY[month - 1] - in_day.start[:day] + 1
|
514
|
+
else
|
515
|
+
MONTH_END_DAY[month - 1]
|
516
|
+
end
|
532
517
|
end
|
533
518
|
for month in 1..in_day.end[:month]
|
534
|
-
if month == in_day.end[:month]
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
519
|
+
days_count += if month == in_day.end[:month]
|
520
|
+
in_day.end[:day]
|
521
|
+
else
|
522
|
+
MONTH_END_DAY[month - 1]
|
523
|
+
end
|
539
524
|
end
|
540
525
|
else
|
541
526
|
for month in in_day.start[:month]..in_day.end[:month]
|
542
|
-
if month == in_day.end[:month]
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
527
|
+
days_count += if month == in_day.end[:month]
|
528
|
+
in_day.end[:day]
|
529
|
+
elsif month == in_day.start[:month]
|
530
|
+
MONTH_END_DAY[month - 1] - in_day.start[:day] + 1
|
531
|
+
else
|
532
|
+
MONTH_END_DAY[month - 1]
|
533
|
+
end
|
549
534
|
end
|
550
535
|
end
|
551
536
|
end
|
@@ -557,19 +542,19 @@ module OpeningHoursConverter
|
|
557
542
|
|
558
543
|
def to_day
|
559
544
|
case @type
|
560
|
-
when
|
545
|
+
when 'day'
|
561
546
|
if @end.nil?
|
562
547
|
OpeningHoursConverter::WideInterval.new.day(@start[:day], @start[:month], @start[:year])
|
563
548
|
else
|
564
549
|
OpeningHoursConverter::WideInterval.new.day(@start[:day], @start[:month], @start[:year], @end[:day], @end[:month], @end[:year])
|
565
550
|
end
|
566
|
-
when
|
551
|
+
when 'month'
|
567
552
|
if @end.nil?
|
568
553
|
OpeningHoursConverter::WideInterval.new.day(1, @start[:month], @start[:year], MONTH_END_DAY[@start[:month] - 1], @start[:month], @start[:year])
|
569
554
|
else
|
570
555
|
OpeningHoursConverter::WideInterval.new.day(1, @start[:month], @start[:year], MONTH_END_DAY[@end[:month] - 1], @end[:month], @end[:year])
|
571
556
|
end
|
572
|
-
when
|
557
|
+
when 'year'
|
573
558
|
if @end.nil?
|
574
559
|
OpeningHoursConverter::WideInterval.new.day(1, 1, @start[:year], 31, 12, @start[:year])
|
575
560
|
else
|
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.8.
|
4
|
+
version: 1.8.1
|
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-
|
11
|
+
date: 2019-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|