opening_hours_converter 1.7.11 → 1.7.12
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ab2dbbd4139cffd6168ebff0c58c44d7d281d6b
|
4
|
+
data.tar.gz: ce505f3caa8ab41b7753b2442cd548962a9c3dd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdfb270d1c926836fb87ca3e3eb547914742a92abcb3ac10049482593f3ec06e40d629e2a1bf8f88a641cd5c7da79943530cc284ec6478df06779e89b779718d
|
7
|
+
data.tar.gz: 78a04fbf46aa03e66958f78cb0e815de6c1bc6b7bd0db5e1129508c3e7b944eec0fbba473bef3b153337817fb6aa6d3a902c54fab7f8ad75f9a77601f68c4b1a
|
@@ -10,6 +10,7 @@ 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
|
+
|
13
14
|
result = []
|
14
15
|
|
15
16
|
year_start = -1
|
@@ -69,8 +70,6 @@ module OpeningHoursConverter
|
|
69
70
|
end
|
70
71
|
date_ranges_array = get_iterator(date_ranges)
|
71
72
|
datetime_result = []
|
72
|
-
|
73
|
-
|
74
73
|
date_ranges_array.each_with_index do |result, index|
|
75
74
|
result.each do |interval|
|
76
75
|
(interval[:start]..interval[:end]).each do |day|
|
@@ -90,7 +89,6 @@ module OpeningHoursConverter
|
|
90
89
|
end
|
91
90
|
end
|
92
91
|
end
|
93
|
-
|
94
92
|
datetime_result.sort {|a,b| a[:start] <=> b[:start]}
|
95
93
|
|
96
94
|
end
|
@@ -135,6 +133,7 @@ module OpeningHoursConverter
|
|
135
133
|
def next_state(opening_hours_string, time=Time.now)
|
136
134
|
date_ranges = OpeningHoursConverter::OpeningHoursParser.new.parse(opening_hours_string)
|
137
135
|
ti = get_time_iterator(date_ranges)
|
136
|
+
|
138
137
|
ti.each_with_index do |interval, index|
|
139
138
|
return {end: interval[:end]} if interval[:start] <= time && interval[:end] >= time
|
140
139
|
return {start: interval[:start]} if interval[:start] > time && ti[index-1][:end] <= time
|
@@ -89,20 +89,20 @@ module OpeningHoursConverter
|
|
89
89
|
|
90
90
|
def self.ph_for_year(year=Time.now.year)
|
91
91
|
ph = []
|
92
|
-
ph << new_year
|
93
|
-
ph << good_friday
|
94
|
-
ph << easter
|
95
|
-
ph << easter_monday
|
96
|
-
ph << work_day
|
97
|
-
ph << victory
|
98
|
-
ph << rise
|
99
|
-
ph << pentecote
|
100
|
-
ph << pentecote_monday
|
101
|
-
ph << bastille_day
|
102
|
-
ph << assomption
|
103
|
-
ph << toussaint
|
104
|
-
ph << armistice
|
105
|
-
ph << christmas
|
92
|
+
ph << new_year(year)
|
93
|
+
ph << good_friday(year)
|
94
|
+
ph << easter(year)
|
95
|
+
ph << easter_monday(year)
|
96
|
+
ph << work_day(year)
|
97
|
+
ph << victory(year)
|
98
|
+
ph << rise(year)
|
99
|
+
ph << pentecote(year)
|
100
|
+
ph << pentecote_monday(year)
|
101
|
+
ph << bastille_day(year)
|
102
|
+
ph << assomption(year)
|
103
|
+
ph << toussaint(year)
|
104
|
+
ph << armistice(year)
|
105
|
+
ph << christmas(year)
|
106
106
|
ph.sort
|
107
107
|
end
|
108
108
|
|
@@ -6,25 +6,22 @@ module OpeningHoursConverter
|
|
6
6
|
|
7
7
|
def self.build_day_array_from_date_range(date_range, get_iterator=false)
|
8
8
|
years = {}
|
9
|
+
|
9
10
|
if date_range.is_holiday? && get_iterator
|
10
|
-
if date_range.wide_interval.
|
11
|
-
if !date_range.wide_interval.
|
12
|
-
|
13
|
-
|
14
|
-
years[year] ||= Array.new(OSM_MONTHS.length) { |i| Array.new(MONTH_END_DAY[i]) { false } }
|
15
|
-
end
|
16
|
-
years = process_holidays(date_range.wide_interval, years)
|
17
|
-
else
|
18
|
-
years[date_range.wide_interval.start[:year]] ||= Array.new(OSM_MONTHS.length) { |i| Array.new(MONTH_END_DAY[i]) { false } }
|
19
|
-
years = process_holidays(date_range.wide_interval, years)
|
11
|
+
if !date_range.wide_interval.start.nil? && !date_range.wide_interval.start[:year].nil?
|
12
|
+
if !date_range.wide_interval.end.nil?
|
13
|
+
for year in date_range.wide_interval.start[:year]..date_range.wide_interval.end[:year]
|
14
|
+
years[year] ||= Array.new(OSM_MONTHS.length) { |i| Array.new(MONTH_END_DAY[i]) { false } }
|
20
15
|
end
|
16
|
+
years = process_holidays(date_range.wide_interval, years)
|
21
17
|
else
|
22
|
-
|
23
|
-
|
24
|
-
years = process_always_holiday(date_range.wide_interval, years)
|
18
|
+
years[date_range.wide_interval.start[:year]] ||= Array.new(OSM_MONTHS.length) { |i| Array.new(MONTH_END_DAY[i]) { false } }
|
19
|
+
years = process_holidays(date_range.wide_interval, years)
|
25
20
|
end
|
26
21
|
else
|
22
|
+
remove_holiday!(date_range)
|
27
23
|
|
24
|
+
years = process_always_holiday(date_range.wide_interval, years)
|
28
25
|
end
|
29
26
|
end
|
30
27
|
if !date_range.wide_interval.start.nil? && !date_range.wide_interval.start[:year].nil?
|
@@ -51,7 +48,7 @@ module OpeningHoursConverter
|
|
51
48
|
end
|
52
49
|
|
53
50
|
def self.process_holidays(wide_interval, years)
|
54
|
-
if !wide_interval.end[:year].nil?
|
51
|
+
if !wide_interval.end.nil? && !wide_interval.end[:year].nil?
|
55
52
|
holidays = {}
|
56
53
|
for year in wide_interval.start[:year]..wide_interval.end[:year]
|
57
54
|
PublicHoliday.ph_for_year(year).each do |ht|
|
@@ -78,7 +75,7 @@ module OpeningHoursConverter
|
|
78
75
|
|
79
76
|
def self.remove_holiday!(date_range)
|
80
77
|
date_range.typical.intervals.each_with_index do |interval, interval_index|
|
81
|
-
date_range.remove_interval(interval_index) if interval.day_start == -2 && interval.day_end == -2
|
78
|
+
date_range.typical.remove_interval(interval_index) if interval.day_start == -2 && interval.day_end == -2
|
82
79
|
end
|
83
80
|
end
|
84
81
|
|
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.
|
4
|
+
version: 1.7.12
|
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-
|
11
|
+
date: 2018-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|