opening_hours_converter 1.13.8 → 1.13.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
  SHA256:
3
- metadata.gz: 246bb142155bcbb71be257921ab532cab3db6a7a266e141d63d8a5a7ddd45ddc
4
- data.tar.gz: 625fda5fdacbd0d87010df460b46113de0307c9fdbf3b646f66863c8d958f909
3
+ metadata.gz: e29118b6122f0fc757389c3ce244c801abea8f3122d335ab6263f6bce8666d3c
4
+ data.tar.gz: 6aae2c87f2b7a50c9bb7545d3f2d25f923bd367519c175abb56bcb8a88e19656
5
5
  SHA512:
6
- metadata.gz: 363ac0c2e07547bbcb68524bfd9c77e5e751062576baf4af0a8ba593e10fb2c24066d8e10a2b6f86516547fc6f394372e87bedc42dec1682be3bc0ba645cf374
7
- data.tar.gz: f386100e7b74a1eaeebac6eb9c15a88255f7e6f9769e6b5a57a4f8afa4e19904ba7ee232bd4a923ffa3ddbcb5c269c1d471fce23620dbd1f0bc52ef03e266d80
6
+ metadata.gz: 5c7d01fc34eefa92f860a35f5bd6dab8f5916b64fd29aa07cb1b9a472a9b383a18d6c5eb96a2e74c29a1a0e2f593e449ac2852a0f095226dc8cf27715567cbe0
7
+ data.tar.gz: '09790d8bd019f108e65714b546a62d8c82d706d17289f1a90eb616b1d68e9472c545470d33ca784c3fc6662e4d8337762abeb1a4476bbd38cb0dbd1038e2f1b0'
@@ -107,7 +107,7 @@ module OpeningHoursConverter
107
107
  elsif !(@regex_handler.month_day_regex =~ wide_range_selector).nil?
108
108
  months << get_month_day(wide_range_selector)
109
109
  elsif !(@regex_handler.month_regex =~ wide_range_selector).nil?
110
- months << get_month(wide_range_selector)
110
+ months += get_month(wide_range_selector)
111
111
  elsif !(@regex_handler.year_regex =~ wide_range_selector).nil?
112
112
  years << get_year(wide_range_selector)
113
113
  elsif !(@regex_handler.multi_month_regex =~ wide_range_selector).nil?
@@ -408,7 +408,23 @@ module OpeningHoursConverter
408
408
  else
409
409
  month_to = month_from
410
410
  end
411
- { from: month_from, to: month_to }
411
+
412
+ if month_from > month_to
413
+ [
414
+ {
415
+ from: month_from,
416
+ to: 12
417
+ },
418
+ {
419
+ from: 1,
420
+ to: month_to
421
+ }
422
+ ]
423
+ else
424
+ [
425
+ { from: month_from, to: month_to }
426
+ ]
427
+ end
412
428
  end
413
429
 
414
430
  def get_month_day(wrs)
@@ -429,6 +445,7 @@ module OpeningHoursConverter
429
445
  else
430
446
  month_to = nil
431
447
  end
448
+
432
449
  { from_day: month_from, to_day: month_to }
433
450
  end
434
451
 
@@ -500,9 +517,12 @@ module OpeningHoursConverter
500
517
 
501
518
  def get_year_multi_month_day(wrs)
502
519
  year = wrs[0...4]
503
- wrs = wrs[5..wrs.length]
504
520
 
505
- wrs.split(',').map do |wr|
521
+ wrs.split(',').map.with_index do |wr|
522
+ if wr =~ /^#{@regex_handler.year}/
523
+ year = wr[0...4]
524
+ wr = wr[5...wr.length]
525
+ end
506
526
  month = wr[0...3]
507
527
  days = wr[4...wr.length].split('-').reject { |e| e == '' }.map(&:to_i)
508
528
  if days.length == 2
@@ -531,25 +551,36 @@ module OpeningHoursConverter
531
551
  def get_multi_month(wrs)
532
552
  wrs.split(',').map do |wr|
533
553
  if wr.include?('-')
534
- start_month, end_month = wr.split('-')
554
+ start_month_day, end_month_day = wr.split('-')
555
+
556
+ start_month = start_month_day[0...3]
557
+ start_day = start_month_day[4...start_month_day.length]&.to_i
558
+
559
+ end_month = end_month_day[0...3]
560
+ end_day = end_month_day[4...end_month_day.length]&.to_i
561
+
535
562
  from = {
536
563
  month: OSM_MONTHS.find_index(start_month) + 1,
537
- day: 1
564
+ day: start_day || 1
538
565
  }
539
566
  to = {
540
567
  month: OSM_MONTHS.find_index(end_month) + 1,
541
- day: MONTH_END_DAY[OSM_MONTHS.find_index(end_month)]
568
+ day: end_day || MONTH_END_DAY[OSM_MONTHS.find_index(end_month)]
542
569
  }
543
570
  else
571
+ month = wr[0...3]
572
+ day = wr[4...wr.length]&.to_i
573
+
544
574
  from = {
545
- month: OSM_MONTHS.find_index(wr[0...3]) + 1,
546
- day: 1
575
+ month: OSM_MONTHS.find_index(month) + 1,
576
+ day: day || 1
547
577
  }
548
578
  to = {
549
- month: OSM_MONTHS.find_index(wr[0...3]) + 1,
550
- day: MONTH_END_DAY[OSM_MONTHS.find_index(wr[0...3])]
579
+ month: OSM_MONTHS.find_index(month) + 1,
580
+ day: day || MONTH_END_DAY[OSM_MONTHS.find_index(month)]
551
581
  }
552
582
  end
583
+
553
584
  { from_day: from, to_day: to }
554
585
  end
555
586
  end
@@ -163,6 +163,7 @@ module OpeningHoursConverter
163
163
  line(
164
164
  year + space +
165
165
  potential_list(
166
+ potential(year + space) +
166
167
  month +
167
168
  group(
168
169
  space, potential_range(month_day)
@@ -177,7 +178,20 @@ module OpeningHoursConverter
177
178
  end
178
179
 
179
180
  def multi_month_regex
180
- compile(line(potential_list(potential_range(month))))
181
+ compile(
182
+ line(
183
+ potential_list(
184
+ potential_range(
185
+ month +
186
+ potential(
187
+ group(
188
+ space, potential_range(month_day)
189
+ )
190
+ )
191
+ )
192
+ )
193
+ )
194
+ )
181
195
  end
182
196
 
183
197
  def week_value_regex
@@ -53,25 +53,25 @@ module OpeningHoursConverter
53
53
  when 'day'
54
54
  if !@end.nil?
55
55
  if @start[:year] && !@end[:year] || @start[:year] && @start[:year] == @end[:year]
56
- result = "du #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} au #{@end[:day]} #{IRL_MONTHS[@end[:month] - 1]} #{@start[:year]}"
56
+ result = "Du #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} au #{@end[:day]} #{IRL_MONTHS[@end[:month] - 1]} #{@start[:year]}"
57
57
  elsif @start[:year] && @end[:year] && @start[:year] != @end[:year]
58
- result = "du #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} au #{@end[:day]} #{IRL_MONTHS[@end[:month] - 1]} #{@end[:year]}"
58
+ result = "Du #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} au #{@end[:day]} #{IRL_MONTHS[@end[:month] - 1]} #{@end[:year]}"
59
59
  elsif @start[:month] != @end[:month]
60
- result = "du #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} au #{@end[:day]} #{IRL_MONTHS[@end[:month] - 1]}"
60
+ result = "Du #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} au #{@end[:day]} #{IRL_MONTHS[@end[:month] - 1]}"
61
61
  else
62
- result = "le #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]}"
62
+ result = "Le #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]}"
63
63
  end
64
64
  else
65
- result = "le #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year] || ''}"
65
+ result = "Le #{@start[:day]} #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year] || ''}"
66
66
  end
67
67
  when 'month'
68
68
  if !@end.nil?
69
69
  if @start[:year] && !@end[:year] || @start[:year] && @start[:year] == @end[:year]
70
- result = "de #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} à #{IRL_MONTHS[@end[:month] - 1]} #{@start[:year]}"
70
+ result = "De #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} à #{IRL_MONTHS[@end[:month] - 1]} #{@start[:year]}"
71
71
  elsif @start[:year] && @end[:year] && @start[:year] != @end[:year]
72
- result = "de #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} à #{IRL_MONTHS[@end[:month] - 1]} #{@end[:year]}"
72
+ result = "De #{IRL_MONTHS[@start[:month] - 1]} #{@start[:year]} à #{IRL_MONTHS[@end[:month] - 1]} #{@end[:year]}"
73
73
  else
74
- result = "de #{IRL_MONTHS[@start[:month] - 1]} à #{IRL_MONTHS[@end[:month] - 1]}"
74
+ result = "De #{IRL_MONTHS[@start[:month] - 1]} à #{IRL_MONTHS[@end[:month] - 1]}"
75
75
  end
76
76
  else
77
77
  result = "#{IRL_MONTHS[@start[:month] - 1]}#{@start[:year] ? " #{@start[:year]}" : ''}"
@@ -85,17 +85,17 @@ module OpeningHoursConverter
85
85
  when 'holiday'
86
86
  result = if !@end.nil?
87
87
  if !@start[:year]
88
- 'jours fériés'
88
+ 'Jours fériés'
89
89
  else
90
- "les jours fériés de #{@start[:year]} à #{@end[:year]}"
90
+ "Les jours fériés de #{@start[:year]} à #{@end[:year]}"
91
91
  end
92
92
  elsif !@start[:year]
93
- 'jours fériés'
93
+ 'Jours fériés'
94
94
  else
95
- "les jours fériés de #{@start[:year]}"
95
+ "Les jours fériés de #{@start[:year]}"
96
96
  end
97
97
  when 'always'
98
- result = 'tout le temps'
98
+ result = 'Toute l\'année'
99
99
  end
100
100
  result
101
101
  end
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.13.8
4
+ version: 1.13.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: 2020-02-24 00:00:00.000000000 Z
11
+ date: 2020-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -115,8 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubyforge_project:
119
- rubygems_version: 2.7.10
118
+ rubygems_version: 3.1.2
120
119
  signing_key:
121
120
  specification_version: 4
122
121
  summary: Datetime range to opening hours, opening hours to datetime range