opening_hours_converter 1.3.12 → 1.3.13.pre

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: 4f468692db741b2e791f1d07c77e3bec3e33834d
4
- data.tar.gz: bfca0d4c43a2289e81e86ca6e61da95a8cae06e6
3
+ metadata.gz: 0f8300647eed6a06164551486a8c975ba7da0bf6
4
+ data.tar.gz: 168520c8f04c0bb5c05fbf2a3850d7f9f8855ee6
5
5
  SHA512:
6
- metadata.gz: 4b5fd9166b85dca915151fd37f76e8bbe5f232e6be53521befbf9f84c3b8e14f17152a07362ee21340cf3d929e61f703967672a0cb6e3ae31e0c4d08a68d6781
7
- data.tar.gz: 711baa863a46bfa94dc5d842df3e0a3b699ff50e4229c9182214d1fd8b0c309f0f08350b12b4eea9677dcf2d0a6cb4f896170d76a15c24fe344805f986df16dd
6
+ metadata.gz: 70897a8abe7db86aa64436912b35c10c759f6b489a0a9704cec9723500e948b04cf50fc93951a3906eb13e3fe09c45ae6ab429c49be0bf6b7136f8c1f49f7091
7
+ data.tar.gz: 25311fc4039e2fca97e8535b7a1f6b8d6c6fbf5c97a523791d990b96ec4441e9361c3f01eca1c481bdb999c5d92a6ee7730f6534352ea0e9a4da7bfcca4f280d
@@ -260,6 +260,37 @@ module OpeningHoursConverter
260
260
  return result
261
261
  end
262
262
 
263
+ def from_json(json)
264
+ ret_date_ranges = []
265
+
266
+ parsed = JSON.parse(json)
267
+ parsed.each do |date_ranges|
268
+ date_range = OpeningHoursConverter::DateRange.new
269
+ date_ranges.each do |dr|
270
+ wi = {}
271
+ start_day = DateTime.parse(dr["wide_interval"]["start"])
272
+ end_day = DateTime.parse(dr["wide_interval"]["end"])
273
+ case dr["wide_interval"]
274
+ when "always"
275
+ wi = OpeningHoursConverter::WideInterval.new.day(start_day.day, start_day.month, nil, end_day.day, end_day.month)
276
+ else
277
+ wi = OpeningHoursConverter::WideInterval.new.day(start_day.day, start_day.month, start_day.year, end_day.day, end_day.month, end_day.year)
278
+ end
279
+ date_range = OpeningHoursConverter::DateRange.new(wi)
280
+ dr["typical"]["intervals"].each do |interval|
281
+ if !interval.nil?
282
+ start_interval = DateTime.parse(interval["start"])
283
+ end_interval = DateTime.parse(interval["end"])
284
+ date_range.typical.add_interval(OpeningHoursConverter::Interval.new(((start_interval.wday + 6) % 7), (start_interval.hour * 60 + start_interval.min), ((end_interval.wday + 6) % 7), (end_interval.hour * 60 + end_interval.min)))
285
+ end
286
+ end
287
+ date_range.add_comment(dr["comment"])
288
+ ret_date_ranges << [date_range]
289
+ end
290
+ end
291
+ ret_date_ranges
292
+ end
293
+
263
294
  def get_year(wrs)
264
295
  single_year = wrs.gsub(/\:$/, '').split('-')
265
296
  year_from = single_year[0].to_i
@@ -35,6 +35,38 @@ module OpeningHoursConverter
35
35
  end
36
36
  end
37
37
 
38
+ def self.new_year(year=Time.now.year)
39
+ Time.new(year, 1, 1)
40
+ end
41
+
42
+ def self.christmas(year=Time.now.year)
43
+ Time.new(year, 12, 25)
44
+ end
45
+
46
+ def self.assomption(year=Time.now.year)
47
+ Time.new(year, 8, 15)
48
+ end
49
+
50
+ def self.work_day(year=Time.now.year)
51
+ Time.new(year, 5, 1)
52
+ end
53
+
54
+ def self.toussaint(year=Time.now.year)
55
+ Time.new(year, 11, 1)
56
+ end
57
+
58
+ def self.victory(year=Time.now.year)
59
+ Time.new(year, 5, 8)
60
+ end
61
+
62
+ def self.armistice(year=Time.now.year)
63
+ Time.new(year, 11, 11)
64
+ end
65
+
66
+ def self.bastille_day(year=Time.now.year)
67
+ Time.new(year, 7, 14)
68
+ end
69
+
38
70
  def self.easter_monday(year=Time.now.year)
39
71
  easter(year) + days(1)
40
72
  end
@@ -43,7 +75,7 @@ module OpeningHoursConverter
43
75
  easter(year) - days(2)
44
76
  end
45
77
 
46
- def self.ascension(year=Time.now.year)
78
+ def self.rise(year=Time.now.year)
47
79
  easter(year) + days(39)
48
80
  end
49
81
 
@@ -57,20 +89,20 @@ module OpeningHoursConverter
57
89
 
58
90
  def self.ph_for_year(year=Time.now.year)
59
91
  ph = []
60
- ph << Time.new(year, 1, 1)
92
+ ph << new_year
61
93
  ph << good_friday
62
94
  ph << easter
63
95
  ph << easter_monday
64
- ph << Time.new(year, 5, 1)
65
- ph << Time.new(year, 5, 8)
66
- ph << ascension
96
+ ph << work_day
97
+ ph << victory
98
+ ph << rise
67
99
  ph << pentecote
68
100
  ph << pentecote_monday
69
- ph << Time.new(year, 7, 14)
70
- ph << Time.new(year, 8, 15)
71
- ph << Time.new(year, 11, 1)
72
- ph << Time.new(year, 11, 11)
73
- ph << Time.new(year, 12, 25)
101
+ ph << bastille_day
102
+ ph << assomption
103
+ ph << toussaint
104
+ ph << armistice
105
+ ph << christmas
74
106
  ph.sort
75
107
  end
76
108
 
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opening_hours_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.12
4
+ version: 1.3.13.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ziserman Martin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-19 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2017-10-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: Datetime range to openinghours, openinghours to datetime range. Very
14
28
  strongly inspired by yohours.
15
29
  email: tech@publidata.io
@@ -47,9 +61,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
47
61
  version: '0'
48
62
  required_rubygems_version: !ruby/object:Gem::Requirement
49
63
  requirements:
50
- - - ">="
64
+ - - ">"
51
65
  - !ruby/object:Gem::Version
52
- version: '0'
66
+ version: 1.3.1
53
67
  requirements: []
54
68
  rubyforge_project:
55
69
  rubygems_version: 2.6.13