opening_hours_converter 1.3.2 → 1.3.3

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: f8e4e03653c0ff37b313eebc544293f0a94f8e64
4
- data.tar.gz: d5d03ad9394c9fad99f378f5709c79bf511bcd0d
3
+ metadata.gz: 25ce86d8ffc2ccf4916fd0bd5a333987027ce0b1
4
+ data.tar.gz: d021f421176116cc5db3f9fee21c3f00b51176bd
5
5
  SHA512:
6
- metadata.gz: d3c40e4249a5d4ad180fc57f0a570278d12154b572332de6c623c442f70304fa8670ebe2079bd707d4597a213692f959f67a33d702034f7cd782a74e8ba74914
7
- data.tar.gz: 6637cfb3f4a33c807247cf7589ce2da1f43bca1848e816e4af10ca88b8f8c26ad526d3f5a3767d367b7bc5a9422fba756542a6fb1219bf4f2b37502efcec9e81
6
+ metadata.gz: 7b405cb629126f8a3b0c929efcd79deec97899d190ca62ac0b76eed79b9fa038284bccec28b4edac35d363e9c510f973997abcf158620e074799c917b743a1a2
7
+ data.tar.gz: c1bb4e43cdc27b9477871803ffe50dd90bc1249b93d743765a431369e6e2d573213b20697f72774bb3a0631da5cb1163a827a02bce25bb8926af2781c096f97a
@@ -0,0 +1,81 @@
1
+ module OpeningHoursConverter
2
+ class PublicHoliday
3
+ def self.easter(year=Time.now.year)
4
+ # code from https://github.com/jrobertson/easter
5
+ golden_number = (year % 19) + 1
6
+
7
+ if year <= 1752 then
8
+ # Julian calendar
9
+ dominical_number = (year + (year / 4) + 5) % 7
10
+ paschal_full_moon = (3 - (11 * golden_number) - 7) % 30
11
+ else
12
+ # Gregorian calendar
13
+ dominical_number = (year + (year / 4) - (year / 100) + (year / 400)) % 7
14
+ solar_correction = (year - 1600) / 100 - (year - 1600) / 400
15
+ lunar_correction = (((year - 1400) / 100) * 8) / 25
16
+ paschal_full_moon = (3 - 11 * golden_number + solar_correction - lunar_correction) % 30
17
+ end
18
+
19
+ dominical_number += 7 until dominical_number > 0
20
+
21
+ paschal_full_moon += 30 until paschal_full_moon > 0
22
+ paschal_full_moon -= 1 if paschal_full_moon == 29 or (paschal_full_moon == 28 and golden_number > 11)
23
+
24
+ difference = (4 - paschal_full_moon - dominical_number) % 7
25
+ difference += 7 if difference < 0
26
+
27
+ day_easter = paschal_full_moon + difference + 1
28
+
29
+ if day_easter < 11 then
30
+ # Easter occurs in March.
31
+ return Time.new(year, 3, day_easter + 21)
32
+ else
33
+ # Easter occurs in April.
34
+ return Time.new(year, 4, day_easter - 10)
35
+ end
36
+ end
37
+
38
+ def self.easter_monday(year=Time.now.year)
39
+ easter(year) + days(1)
40
+ end
41
+
42
+ def self.good_friday(year=Time.now.year)
43
+ easter(year) - days(2)
44
+ end
45
+
46
+ def self.ascension(year=Time.now.year)
47
+ easter(year) + days(39)
48
+ end
49
+
50
+ def self.pentecote(year=Time.now.year)
51
+ easter(year) + days(49)
52
+ end
53
+
54
+ def self.pentecote_monday(year=Time.now.year)
55
+ easter(year) + days(50)
56
+ end
57
+
58
+ def self.ph_for_year(year=Time.now.year)
59
+ ph = []
60
+ ph << Time.new(year, 1, 1)
61
+ ph << good_friday
62
+ ph << easter
63
+ ph << easter_monday
64
+ ph << Time.new(year, 5, 1)
65
+ ph << Time.new(year, 5, 8)
66
+ ph << ascension
67
+ ph << pentecote
68
+ 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)
74
+ ph.sort
75
+ end
76
+
77
+ def self.days(days=0)
78
+ days * 24 * 60 * 60
79
+ end
80
+ end
81
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opening_hours_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ziserman Martin
@@ -28,6 +28,7 @@ files:
28
28
  - lib/opening_hours_converter/opening_hours_parser.rb
29
29
  - lib/opening_hours_converter/opening_hours_rule.rb
30
30
  - lib/opening_hours_converter/opening_hours_time.rb
31
+ - lib/opening_hours_converter/public_holiday.rb
31
32
  - lib/opening_hours_converter/week.rb
32
33
  - lib/opening_hours_converter/wide_interval.rb
33
34
  - lib/opening_hours_converter/year.rb