bahai_date 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,321 @@
1
+ require_relative 'occasion'
2
+
3
+ module BahaiDate
4
+
5
+ class OccasionFactory
6
+
7
+ OCCASIONS = {
8
+ :ayyam_i_ha_1 => { :type => :ayyam_i_ha, :work_suspended => false, :title => "First day of Ayyam-i-Ha (Intercalery Days)", :short_title => "1st day of Ayyam-i-Ha", :title_html => "First day of Ayyám-i-Há (Intercalery Days)", :short_title_html => "1<sup>st</sup> day of Ayyám-i-Há" },
9
+ :ayyam_i_ha_2 => { :type => :ayyam_i_ha, :work_suspended => false, :title => "Second day of Ayyam-i-Ha (Intercalery Days)", :short_title => "2nd day of Ayyam-i-Ha", :title_html => "Second day of Ayyám-i-Há (Intercalery Days)", :short_title_html => "2<sup>nd</sup> day of Ayyám-i-Há" },
10
+ :ayyam_i_ha_3 => { :type => :ayyam_i_ha, :work_suspended => false, :title => "Third day of Ayyam-i-Ha (Intercalery Days)", :short_title => "3rd day of Ayyam-i-Ha", :title_html => "Third day of Ayyám-i-Há (Intercalery Days)", :short_title_html => "3<sup>rd</sup> day of Ayyám-i-Há" },
11
+ :ayyam_i_ha_4 => { :type => :ayyam_i_ha, :work_suspended => false, :title => "Fourth day of Ayyam-i-Ha (Intercalery Days)", :short_title => "4th day of Ayyam-i-Ha", :title_html => "Fourth day of Ayyám-i-Há (Intercalery Days)", :short_title_html => "4<sup>th</sup> day of Ayyám-i-Há" },
12
+ :ayyam_i_ha_5 => { :type => :ayyam_i_ha, :work_suspended => false, :title => "Fifth day of Ayyam-i-Ha (Intercalery Days)", :short_title => "5th day of Ayyam-i-Ha", :title_html => "Fifth day of Ayyám-i-Há (Intercalery Days)", :short_title_html => "5<sup>th</sup> day of Ayyám-i-Há" },
13
+ :fasting_1 => { :type => :fasting, :work_suspended => false, :title => "First day of the period of Fasting", :short_title => "1st day of Fasting", :title_html => "First day of the period of Fasting", :short_title_html => "1<sup>st</sup> day of Fasting" },
14
+ :fasting_2 => { :type => :fasting, :work_suspended => false, :title => "Second day of the period of Fasting", :short_title => "2nd day of Fasting", :title_html => "Second day of the period of Fasting", :short_title_html => "2<sup>nd</sup> day of Fasting" },
15
+ :fasting_3 => { :type => :fasting, :work_suspended => false, :title => "Third day of the period of Fasting", :short_title => "3rd day of Fasting", :title_html => "Third day of the period of Fasting", :short_title_html => "3<sup>rd</sup> day of Fasting" },
16
+ :fasting_4 => { :type => :fasting, :work_suspended => false, :title => "Fourth day of the period of Fasting", :short_title => "4th day of Fasting", :title_html => "Fourth day of the period of Fasting", :short_title_html => "4<sup>th</sup> day of Fasting" },
17
+ :fasting_5 => { :type => :fasting, :work_suspended => false, :title => "Fifth day of the period of Fasting", :short_title => "5th day of Fasting", :title_html => "Fifth day of the period of Fasting", :short_title_html => "5<sup>th</sup> day of Fasting" },
18
+ :fasting_6 => { :type => :fasting, :work_suspended => false, :title => "Sixth day of the period of Fasting", :short_title => "6th day of Fasting", :title_html => "Sixth day of the period of Fasting", :short_title_html => "6<sup>th</sup> day of Fasting" },
19
+ :fasting_7 => { :type => :fasting, :work_suspended => false, :title => "Seventh day of the period of Fasting", :short_title => "7th day of Fasting", :title_html => "Seventh day of the period of Fasting", :short_title_html => "7<sup>th</sup> day of Fasting" },
20
+ :fasting_8 => { :type => :fasting, :work_suspended => false, :title => "Eighth day of the period of Fasting", :short_title => "8th day of Fasting", :title_html => "Eighth day of the period of Fasting", :short_title_html => "8<sup>th</sup> day of Fasting" },
21
+ :fasting_9 => { :type => :fasting, :work_suspended => false, :title => "Ninth day of the period of Fasting", :short_title => "9th day of Fasting", :title_html => "Ninth day of the period of Fasting", :short_title_html => "9<sup>th</sup> day of Fasting" },
22
+ :fasting_10 => { :type => :fasting, :work_suspended => false, :title => "Tenth day of the period of Fasting", :short_title => "10th day of Fasting", :title_html => "Tenth day of the period of Fasting", :short_title_html => "10<sup>th</sup> day of Fasting" },
23
+ :fasting_11 => { :type => :fasting, :work_suspended => false, :title => "Eleventh day of the period of Fasting", :short_title => "11th day of Fasting", :title_html => "Eleventh day of the period of Fasting", :short_title_html => "11<sup>th</sup> day of Fasting" },
24
+ :fasting_12 => { :type => :fasting, :work_suspended => false, :title => "Twelfth day of the period of Fasting", :short_title => "12th day of Fasting", :title_html => "Twelfth day of the period of Fasting", :short_title_html => "12<sup>th</sup> day of Fasting" },
25
+ :fasting_13 => { :type => :fasting, :work_suspended => false, :title => "Thirteenth day of the period of Fasting", :short_title => "13th day of Fasting", :title_html => "Thirteenth day of the period of Fasting", :short_title_html => "13<sup>th</sup> day of Fasting" },
26
+ :fasting_14 => { :type => :fasting, :work_suspended => false, :title => "Fourteenth day of the period of Fasting", :short_title => "14th day of Fasting", :title_html => "Fourteenth day of the period of Fasting", :short_title_html => "14<sup>th</sup> day of Fasting" },
27
+ :fasting_15 => { :type => :fasting, :work_suspended => false, :title => "Fifteenth day of the period of Fasting", :short_title => "15th day of Fasting", :title_html => "Fifteenth day of the period of Fasting", :short_title_html => "15<sup>th</sup> day of Fasting" },
28
+ :fasting_16 => { :type => :fasting, :work_suspended => false, :title => "Sixteenth day of the period of Fasting", :short_title => "16th day of Fasting", :title_html => "Sixteenth day of the period of Fasting", :short_title_html => "16<sup>th</sup> day of Fasting" },
29
+ :fasting_17 => { :type => :fasting, :work_suspended => false, :title => "Seventeenth day of the period of Fasting", :short_title => "17th day of Fasting", :title_html => "Seventeenth day of the period of Fasting", :short_title_html => "17<sup>th</sup> day of Fasting" },
30
+ :fasting_18 => { :type => :fasting, :work_suspended => false, :title => "Eighteenth day of the period of Fasting", :short_title => "18th day of Fasting", :title_html => "Eighteenth day of the period of Fasting", :short_title_html => "18<sup>th</sup> day of Fasting" },
31
+ :fasting_19 => { :type => :fasting, :work_suspended => false, :title => "Nineteenth day of the period of Fasting", :short_title => "19th day of Fasting", :title_html => "Nineteenth day of the period of Fasting", :short_title_html => "19<sup>th</sup> day of Fasting" },
32
+ :feast_1 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Baha (Splendour)", :short_title => "Feast of Baha", :title_html => "Nineteen Day Feast of the month of Bahá (Splendour)", :short_title_html => "Feast of Bahá" },
33
+ :feast_2 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Jalal (Glory)", :short_title => "Feast of Jalal", :title_html => "Nineteen Day Feast of the month of Jalál (Glory)", :short_title_html => "Feast of Jalál" },
34
+ :feast_3 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Jamal (Beauty)", :short_title => "Feast of Jamal", :title_html => "Nineteen Day Feast of the month of Jamál (Beauty)", :short_title_html => "Feast of Jamál" },
35
+ :feast_4 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Azamat (Grandeur)", :short_title => "Feast of Azamat", :title_html => "Nineteen Day Feast of the month of ‘Aẓamat (Grandeur)", :short_title_html => "Feast of ‘Aẓamat" },
36
+ :feast_5 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Nur (Light)", :short_title => "Feast of Nur", :title_html => "Nineteen Day Feast of the month of Núr (Light)", :short_title_html => "Feast of Núr" },
37
+ :feast_6 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Rahmat (Mercy)", :short_title => "Feast of Rahmat", :title_html => "Nineteen Day Feast of the month of Raḥmat (Mercy)", :short_title_html => "Feast of Raḥmat" },
38
+ :feast_7 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Kalimat (Words)", :short_title => "Feast of Kalimat", :title_html => "Nineteen Day Feast of the month of Kalimát (Words)", :short_title_html => "Feast of Kalimát" },
39
+ :feast_8 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Kamal (Perfection)", :short_title => "Feast of Kamal", :title_html => "Nineteen Day Feast of the month of Kamál (Perfection)", :short_title_html => "Feast of Kamál" },
40
+ :feast_9 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Asma (Names)", :short_title => "Feast of Asma", :title_html => "Nineteen Day Feast of the month of Asmá’ (Names)", :short_title_html => "Feast of Asmá’" },
41
+ :feast_10 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Izzat (Might)", :short_title => "Feast of Izzat", :title_html => "Nineteen Day Feast of the month of ‘Izzat (Might)", :short_title_html => "Feast of ‘Izzat" },
42
+ :feast_11 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Mashiyyat (Will)", :short_title => "Feast of Mashiyyat", :title_html => "Nineteen Day Feast of the month of Ma<u>sh</u>íyyat (Will)", :short_title_html => "Feast of Ma<u>sh</u>íyyat" },
43
+ :feast_12 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Ilm (Knowledge)", :short_title => "Feast of Ilm", :title_html => "Nineteen Day Feast of the month of ‘Ilm (Knowledge)", :short_title_html => "Feast of ‘Ilm" },
44
+ :feast_13 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Qudrat (Power)", :short_title => "Feast of Qudrat", :title_html => "Nineteen Day Feast of the month of Qudrat (Power)", :short_title_html => "Feast of Qudrat" },
45
+ :feast_14 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Qawl (Speech)", :short_title => "Feast of Qawl", :title_html => "Nineteen Day Feast of the month of Qawl (Speech)", :short_title_html => "Feast of Qawl" },
46
+ :feast_15 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Masail (Questions)", :short_title => "Feast of Masail", :title_html => "Nineteen Day Feast of the month of Masá’il (Questions)", :short_title_html => "Feast of Masá’il" },
47
+ :feast_16 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Sharaf (Honour)", :short_title => "Feast of Sharaf", :title_html => "Nineteen Day Feast of the month of <u>Sh</u>araf (Honour)", :short_title_html => "Feast of <u>Sh</u>araf" },
48
+ :feast_17 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Sultan (Sovereignty)", :short_title => "Feast of Sultan", :title_html => "Nineteen Day Feast of the month of Sulṭán (Sovereignty)", :short_title_html => "Feast of Sulṭán" },
49
+ :feast_18 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Mulk (Dominion)", :short_title => "Feast of Mulk", :title_html => "Nineteen Day Feast of the month of Mulk (Dominion)", :short_title_html => "Feast of Mulk" },
50
+ :feast_19 => { :type => :feast, :work_suspended => false, :title => "Nineteen Day Feast of the month of Ala (Loftiness)", :short_title => "Feast of Ala", :title_html => "Nineteen Day Feast of the month of ‘Alá’ (Loftiness)", :short_title_html => "Feast of ‘Alá’" },
51
+ :ridvan_1 => { :type => :holy, :work_suspended => true, :title => "First day of the Festival of Ridvan", :short_title => "1st day of Ridvan", :title_html => "First day of the Festival of Riḍván", :short_title_html => "1<sup>st</sup> day of Riḍván" },
52
+ :ridvan_2 => { :type => :ridvan, :work_suspended => false, :title => "Second day of the Festival of Ridvan", :short_title => "2nd day of Ridvan", :title_html => "Second day of the Festival of Riḍván", :short_title_html => "2<sup>nd</sup> day of Riḍván" },
53
+ :ridvan_3 => { :type => :ridvan, :work_suspended => false, :title => "Third day of the Festival of Ridvan", :short_title => "3rd day of Ridvan", :title_html => "Third day of the Festival of Riḍván", :short_title_html => "3<sup>rd</sup> day of Riḍván" },
54
+ :ridvan_4 => { :type => :ridvan, :work_suspended => false, :title => "Fourth day of the Festival of Ridvan", :short_title => "4th day of Ridvan", :title_html => "Fourth day of the Festival of Riḍván", :short_title_html => "4<sup>th</sup> day of Riḍván" },
55
+ :ridvan_5 => { :type => :ridvan, :work_suspended => false, :title => "Fifth day of the Festival of Ridvan", :short_title => "5th day of Ridvan", :title_html => "Fifth day of the Festival of Riḍván", :short_title_html => "5<sup>th</sup> day of Riḍván" },
56
+ :ridvan_6 => { :type => :ridvan, :work_suspended => false, :title => "Sixth day of the Festival of Ridvan", :short_title => "6th day of Ridvan", :title_html => "Sixth day of the Festival of Riḍván", :short_title_html => "6<sup>th</sup> day of Riḍván" },
57
+ :ridvan_7 => { :type => :ridvan, :work_suspended => false, :title => "Seventh day of the Festival of Ridvan", :short_title => "7th day of Ridvan", :title_html => "Seventh day of the Festival of Riḍván", :short_title_html => "7<sup>th</sup> day of Riḍván" },
58
+ :ridvan_8 => { :type => :ridvan, :work_suspended => false, :title => "Eighth day of the Festival of Ridvan", :short_title => "8th day of Ridvan", :title_html => "Eighth day of the Festival of Riḍván", :short_title_html => "8<sup>th</sup> day of Riḍván" },
59
+ :ridvan_9 => { :type => :holy, :work_suspended => true, :title => "Ninth day of the Festival of Ridvan", :short_title => "9th day of Ridvan", :title_html => "Ninth day of the Festival of Riḍván", :short_title_html => "9<sup>th</sup> day of Riḍván" },
60
+ :ridvan_10 => { :type => :ridvan, :work_suspended => false, :title => "Tenth day of the Festival of Ridvan", :short_title => "10th day of Ridvan", :title_html => "Tenth day of the Festival of Riḍván", :short_title_html => "10<sup>th</sup> day of Riḍván" },
61
+ :ridvan_11 => { :type => :ridvan, :work_suspended => false, :title => "Eleventh day of the Festival of Ridvan", :short_title => "11th day of Ridvan", :title_html => "Eleventh day of the Festival of Riḍván", :short_title_html => "11<sup>th</sup> day of Riḍván" },
62
+ :ridvan_12 => { :type => :holy, :work_suspended => true, :title => "Twelfth day of the Festival of Ridvan", :short_title => "12th day of Ridvan", :title_html => "Twelfth day of the Festival of Riḍván", :short_title_html => "12<sup>th</sup> day of Riḍván" },
63
+ :nawruz => { :type => :holy, :work_suspended => true, :title => "Naw-Ruz (New Year)", :short_title => "Naw-Ruz", :title_html => "Naw-Rúz (New Year)", :short_title_html => "Naw-Rúz" },
64
+ :declaration_bab => { :type => :holy, :work_suspended => true, :title => "Declaration of the Bab", :short_title => "Declaration of the Bab", :title_html => "Declaration of the Báb", :short_title_html => "Declaration of the Báb" },
65
+ :ascension_bahaullah => { :type => :holy, :work_suspended => true, :title => "Ascension of Baha'u'llah", :short_title => "Ascension of Baha'u'llah", :title_html => "Ascension of Bahá’u’lláh", :short_title_html => "Ascension of Bahá’u’lláh" },
66
+ :martyrdom_bab => { :type => :holy, :work_suspended => true, :title => "Martyrdom of the Bab", :short_title => "Martyrdom of the Bab", :title_html => "Martyrdom of the Báb", :short_title_html => "Martyrdom of the Báb" },
67
+ :birth_bab => { :type => :holy, :work_suspended => true, :title => "Anniversary of the Birth of the Bab", :short_title => "Birth of the Bab", :title_html => "Anniversary of the Birth of the Báb", :short_title_html => "Birth of the Báb" },
68
+ :birth_bahaullah => { :type => :holy, :work_suspended => true, :title => "Anniversary of the Birth of Baha'u'llah", :short_title => "Birth of Baha'u'llah", :title_html => "Anniversary of the Birth of Bahá’u’lláh", :short_title_html => "Birth of Bahá’u’lláh" },
69
+ :covenant => { :type => :holy, :work_suspended => false, :title => "Day of the Covenant", :short_title => "Day of the Covenant", :title_html => "Day of the Covenant", :short_title_html => "Day of the Covenant" },
70
+ :ascension_abdulbaha => { :type => :holy, :work_suspended => false, :title => "Ascension of Abdu'l-Baha", :short_title => "Ascension of Abdu'l-Baha", :title_html => "Ascension of ‘Abdu’l-Bahá", :short_title_html => "Ascension of ‘Abdu’l-Bahá" }
71
+ }
72
+
73
+ DATES = {
74
+ '1.1' => [:nawruz, :feast_1],
75
+ '2.1' => [:feast_2],
76
+ '2.13' => [:ridvan_1],
77
+ '2.14' => [:ridvan_2],
78
+ '2.15' => [:ridvan_3],
79
+ '2.16' => [:ridvan_4],
80
+ '2.17' => [:ridvan_5],
81
+ '2.18' => [:ridvan_6],
82
+ '2.19' => [:ridvan_7],
83
+ '3.1' => [:feast_3, :ridvan_8],
84
+ '3.2' => [:ridvan_9],
85
+ '3.3' => [:ridvan_10],
86
+ '3.4' => [:ridvan_11],
87
+ '3.5' => [:ridvan_12],
88
+ '4.1' => [:feast_4],
89
+ '4.13' => [:ascension_bahaullah],
90
+ '5.1' => [:feast_5],
91
+ '6.1' => [:feast_6],
92
+ '7.1' => [:feast_7],
93
+ '8.1' => [:feast_8],
94
+ '9.1' => [:feast_9],
95
+ '10.1' => [:feast_10],
96
+ '11.1' => [:feast_11],
97
+ '12.1' => [:feast_12],
98
+ '13.1' => [:feast_13],
99
+ '14.1' => [:feast_14],
100
+ '14.4' => [:covenant],
101
+ '14.6' => [:ascension_abdulbaha],
102
+ '15.1' => [:feast_15],
103
+ '16.1' => [:feast_16],
104
+ '17.1' => [:feast_17],
105
+ '18.1' => [:feast_18],
106
+ '-1.1' => [:ayyam_i_ha_1],
107
+ '-1.2' => [:ayyam_i_ha_2],
108
+ '-1.3' => [:ayyam_i_ha_3],
109
+ '-1.4' => [:ayyam_i_ha_4],
110
+ '-1.5' => [:ayyam_i_ha_5],
111
+ '19.1' => [:feast_19, :fasting_1],
112
+ '19.2' => [:fasting_2],
113
+ '19.3' => [:fasting_3],
114
+ '19.4' => [:fasting_4],
115
+ '19.5' => [:fasting_5],
116
+ '19.6' => [:fasting_6],
117
+ '19.7' => [:fasting_7],
118
+ '19.8' => [:fasting_8],
119
+ '19.9' => [:fasting_9],
120
+ '19.10' => [:fasting_10],
121
+ '19.11' => [:fasting_11],
122
+ '19.12' => [:fasting_12],
123
+ '19.13' => [:fasting_13],
124
+ '19.14' => [:fasting_14],
125
+ '19.15' => [:fasting_15],
126
+ '19.16' => [:fasting_16],
127
+ '19.17' => [:fasting_17],
128
+ '19.18' => [:fasting_18],
129
+ '19.19' => [:fasting_19]
130
+ }
131
+
132
+ DATES_BEFORE_172 = {
133
+ '4.7' => [:declaration_bab],
134
+ '6.16' => [:martyrdom_bab],
135
+ '12.5' => [:birth_bab],
136
+ '13.9' => [:birth_bahaullah]
137
+ }
138
+
139
+ DATES_AFTER_172 = {
140
+ '4.8' => [:declaration_bab],
141
+ '6.17' => [:martyrdom_bab]
142
+ }
143
+
144
+ DATES_LUNAR = {
145
+ 172 => { '13.10' => [:birth_bab], '13.11' => [:birth_bahaullah] },
146
+ 173 => { '12.18' => [:birth_bab], '12.19' => [:birth_bahaullah] },
147
+ 174 => { '12.7' => [:birth_bab], '12.8' => [:birth_bahaullah] },
148
+ 175 => { '13.6' => [:birth_bab], '13.7' => [:birth_bahaullah] },
149
+ 176 => { '12.14' => [:birth_bab], '12.15' => [:birth_bahaullah] },
150
+ 177 => { '12.4' => [:birth_bab], '12.5' => [:birth_bahaullah] },
151
+ 178 => { '13.4' => [:birth_bab], '13.5' => [:birth_bahaullah] },
152
+ 179 => { '12.11' => [:birth_bab], '12.12' => [:birth_bahaullah] },
153
+ 180 => { '12.1' => [:birth_bab], '12.2' => [:birth_bahaullah] },
154
+ 181 => { '12.19' => [:birth_bab], '13.1' => [:birth_bahaullah] },
155
+ 182 => { '12.8' => [:birth_bab], '12.9' => [:birth_bahaullah] },
156
+ 183 => { '13.7' => [:birth_bab], '13.8' => [:birth_bahaullah] },
157
+ 184 => { '12.15' => [:birth_bab], '12.16' => [:birth_bahaullah] },
158
+ 185 => { '12.5' => [:birth_bab], '12.6' => [:birth_bahaullah] },
159
+ 186 => { '13.5' => [:birth_bab], '13.6' => [:birth_bahaullah] },
160
+ 187 => { '12.14' => [:birth_bab], '12.15' => [:birth_bahaullah] },
161
+ 188 => { '12.2' => [:birth_bab], '12.3' => [:birth_bahaullah] },
162
+ 189 => { '13.2' => [:birth_bab], '13.3' => [:birth_bahaullah] },
163
+ 190 => { '12.10' => [:birth_bab], '12.11' => [:birth_bahaullah] },
164
+ 191 => { '13.10' => [:birth_bab], '13.11' => [:birth_bahaullah] },
165
+ 192 => { '12.17' => [:birth_bab], '12.18' => [:birth_bahaullah] },
166
+ 193 => { '12.6' => [:birth_bab], '12.7' => [:birth_bahaullah] },
167
+ 194 => { '13.6' => [:birth_bab], '13.7' => [:birth_bahaullah] },
168
+ 195 => { '12.15' => [:birth_bab], '12.16' => [:birth_bahaullah] },
169
+ 196 => { '12.4' => [:birth_bab], '12.5' => [:birth_bahaullah] },
170
+ 197 => { '13.4' => [:birth_bab], '13.5' => [:birth_bahaullah] },
171
+ 198 => { '12.12' => [:birth_bab], '12.13' => [:birth_bahaullah] },
172
+ 199 => { '12.1' => [:birth_bab], '12.2' => [:birth_bahaullah] },
173
+ 200 => { '12.19' => [:birth_bab], '13.1' => [:birth_bahaullah] },
174
+ 201 => { '12.8' => [:birth_bab], '12.9' => [:birth_bahaullah] },
175
+ 202 => { '13.8' => [:birth_bab], '13.9' => [:birth_bahaullah] },
176
+ 203 => { '12.16' => [:birth_bab], '12.17' => [:birth_bahaullah] },
177
+ 204 => { '12.5' => [:birth_bab], '12.6' => [:birth_bahaullah] },
178
+ 205 => { '13.5' => [:birth_bab], '13.6' => [:birth_bahaullah] },
179
+ 206 => { '12.14' => [:birth_bab], '12.15' => [:birth_bahaullah] },
180
+ 207 => { '12.3' => [:birth_bab], '12.4' => [:birth_bahaullah] },
181
+ 208 => { '13.2' => [:birth_bab], '13.3' => [:birth_bahaullah] },
182
+ 209 => { '12.10' => [:birth_bab], '12.11' => [:birth_bahaullah] },
183
+ 210 => { '13.9' => [:birth_bab], '13.10' => [:birth_bahaullah] },
184
+ 211 => { '12.18' => [:birth_bab], '12.19' => [:birth_bahaullah] },
185
+ 212 => { '12.6' => [:birth_bab], '12.7' => [:birth_bahaullah] },
186
+ 213 => { '13.6' => [:birth_bab], '13.7' => [:birth_bahaullah] },
187
+ 214 => { '12.15' => [:birth_bab], '12.16' => [:birth_bahaullah] },
188
+ 215 => { '12.4' => [:birth_bab], '12.5' => [:birth_bahaullah] },
189
+ 216 => { '13.4' => [:birth_bab], '13.5' => [:birth_bahaullah] },
190
+ 217 => { '12.11' => [:birth_bab], '12.12' => [:birth_bahaullah] },
191
+ 218 => { '11.19' => [:birth_bab], '12.1' => [:birth_bahaullah] },
192
+ 219 => { '12.19' => [:birth_bab], '13.1' => [:birth_bahaullah] },
193
+ 220 => { '12.9' => [:birth_bab], '12.10' => [:birth_bahaullah] },
194
+ 221 => { '13.8' => [:birth_bab], '13.9' => [:birth_bahaullah] },
195
+ 222 => { '12.16' => [:birth_bab], '12.17' => [:birth_bahaullah] },
196
+ 223 => { '12.6' => [:birth_bab], '12.7' => [:birth_bahaullah] },
197
+ 224 => { '13.6' => [:birth_bab], '13.7' => [:birth_bahaullah] },
198
+ 225 => { '12.13' => [:birth_bab], '12.14' => [:birth_bahaullah] },
199
+ 226 => { '12.2' => [:birth_bab], '12.3' => [:birth_bahaullah] },
200
+ 227 => { '13.2' => [:birth_bab], '13.3' => [:birth_bahaullah] },
201
+ 228 => { '12.10' => [:birth_bab], '12.11' => [:birth_bahaullah] },
202
+ 229 => { '13.9' => [:birth_bab], '13.10' => [:birth_bahaullah] },
203
+ 230 => { '12.18' => [:birth_bab], '12.19' => [:birth_bahaullah] },
204
+ 231 => { '12.7' => [:birth_bab], '12.8' => [:birth_bahaullah] },
205
+ 232 => { '13.7' => [:birth_bab], '13.8' => [:birth_bahaullah] },
206
+ 233 => { '12.15' => [:birth_bab], '12.16' => [:birth_bahaullah] },
207
+ 234 => { '12.4' => [:birth_bab], '12.5' => [:birth_bahaullah] },
208
+ 235 => { '13.4' => [:birth_bab], '13.5' => [:birth_bahaullah] },
209
+ 236 => { '12.12' => [:birth_bab], '12.13' => [:birth_bahaullah] },
210
+ 237 => { '11.19' => [:birth_bab], '12.1' => [:birth_bahaullah] },
211
+ 238 => { '12.19' => [:birth_bab], '13.1' => [:birth_bahaullah] },
212
+ 239 => { '12.9' => [:birth_bab], '12.10' => [:birth_bahaullah] },
213
+ 240 => { '13.9' => [:birth_bab], '13.10' => [:birth_bahaullah] },
214
+ 241 => { '12.16' => [:birth_bab], '12.17' => [:birth_bahaullah] },
215
+ 242 => { '12.6' => [:birth_bab], '12.7' => [:birth_bahaullah] },
216
+ 243 => { '13.5' => [:birth_bab], '13.6' => [:birth_bahaullah] },
217
+ 244 => { '12.13' => [:birth_bab], '12.14' => [:birth_bahaullah] },
218
+ 245 => { '12.2' => [:birth_bab], '12.3' => [:birth_bahaullah] },
219
+ 246 => { '13.1' => [:birth_bab], '13.2' => [:birth_bahaullah] },
220
+ 247 => { '12.10' => [:birth_bab], '12.11' => [:birth_bahaullah] },
221
+ 248 => { '13.10' => [:birth_bab], '13.11' => [:birth_bahaullah] },
222
+ 249 => { '12.19' => [:birth_bab], '13.1' => [:birth_bahaullah] },
223
+ 250 => { '12.7' => [:birth_bab], '12.8' => [:birth_bahaullah] },
224
+ 251 => { '13.7' => [:birth_bab], '13.8' => [:birth_bahaullah] },
225
+ 252 => { '12.15' => [:birth_bab], '12.16' => [:birth_bahaullah] },
226
+ 253 => { '12.4' => [:birth_bab], '12.5' => [:birth_bahaullah] },
227
+ 254 => { '13.3' => [:birth_bab], '13.4' => [:birth_bahaullah] },
228
+ 255 => { '12.11' => [:birth_bab], '12.12' => [:birth_bahaullah] },
229
+ 256 => { '12.1' => [:birth_bab], '12.2' => [:birth_bahaullah] },
230
+ 257 => { '13.1' => [:birth_bab], '13.2' => [:birth_bahaullah] },
231
+ 258 => { '12.9' => [:birth_bab], '12.10' => [:birth_bahaullah] },
232
+ 259 => { '13.9' => [:birth_bab], '13.10' => [:birth_bahaullah] },
233
+ 260 => { '12.17' => [:birth_bab], '12.18' => [:birth_bahaullah] },
234
+ 261 => { '12.6' => [:birth_bab], '12.7' => [:birth_bahaullah] },
235
+ 262 => { '13.5' => [:birth_bab], '13.6' => [:birth_bahaullah] },
236
+ 263 => { '12.13' => [:birth_bab], '12.14' => [:birth_bahaullah] },
237
+ 264 => { '12.2' => [:birth_bab], '12.3' => [:birth_bahaullah] },
238
+ 265 => { '13.2' => [:birth_bab], '13.3' => [:birth_bahaullah] },
239
+ 266 => { '12.10' => [:birth_bab], '12.11' => [:birth_bahaullah] },
240
+ 267 => { '13.10' => [:birth_bab], '13.11' => [:birth_bahaullah] },
241
+ 268 => { '12.19' => [:birth_bab], '13.1' => [:birth_bahaullah] },
242
+ 269 => { '12.8' => [:birth_bab], '12.9' => [:birth_bahaullah] },
243
+ 270 => { '13.7' => [:birth_bab], '13.8' => [:birth_bahaullah] },
244
+ 271 => { '12.15' => [:birth_bab], '12.16' => [:birth_bahaullah] },
245
+ 272 => { '12.4' => [:birth_bab], '12.5' => [:birth_bahaullah] },
246
+ 273 => { '13.4' => [:birth_bab], '13.5' => [:birth_bahaullah] },
247
+ 274 => { '12.11' => [:birth_bab], '12.12' => [:birth_bahaullah] },
248
+ 275 => { '12.1' => [:birth_bab], '12.2' => [:birth_bahaullah] },
249
+ 276 => { '13.1' => [:birth_bab], '13.2' => [:birth_bahaullah] },
250
+ 277 => { '12.9' => [:birth_bab], '12.10' => [:birth_bahaullah] },
251
+ 278 => { '13.8' => [:birth_bab], '13.9' => [:birth_bahaullah] },
252
+ 279 => { '12.16' => [:birth_bab], '12.17' => [:birth_bahaullah] },
253
+ 280 => { '12.5' => [:birth_bab], '12.6' => [:birth_bahaullah] },
254
+ 281 => { '13.5' => [:birth_bab], '13.6' => [:birth_bahaullah] },
255
+ 282 => { '12.14' => [:birth_bab], '12.15' => [:birth_bahaullah] },
256
+ 283 => { '12.2' => [:birth_bab], '12.3' => [:birth_bahaullah] },
257
+ 284 => { '13.2' => [:birth_bab], '13.3' => [:birth_bahaullah] },
258
+ 285 => { '12.11' => [:birth_bab], '12.12' => [:birth_bahaullah] },
259
+ 286 => { '13.11' => [:birth_bab], '13.12' => [:birth_bahaullah] },
260
+ 287 => { '12.18' => [:birth_bab], '12.19' => [:birth_bahaullah] },
261
+ 288 => { '12.7' => [:birth_bab], '12.8' => [:birth_bahaullah] },
262
+ 289 => { '13.7' => [:birth_bab], '13.8' => [:birth_bahaullah] },
263
+ 290 => { '12.15' => [:birth_bab], '12.16' => [:birth_bahaullah] },
264
+ 291 => { '12.4' => [:birth_bab], '12.5' => [:birth_bahaullah] },
265
+ 292 => { '13.4' => [:birth_bab], '13.5' => [:birth_bahaullah] },
266
+ 293 => { '12.12' => [:birth_bab], '12.13' => [:birth_bahaullah] },
267
+ 294 => { '12.2' => [:birth_bab], '12.3' => [:birth_bahaullah] },
268
+ 295 => { '13.1' => [:birth_bab], '13.2' => [:birth_bahaullah] },
269
+ 296 => { '12.9' => [:birth_bab], '12.10' => [:birth_bahaullah] },
270
+ 297 => { '13.9' => [:birth_bab], '13.10' => [:birth_bahaullah] },
271
+ 298 => { '12.17' => [:birth_bab], '12.18' => [:birth_bahaullah] },
272
+ 299 => { '12.5' => [:birth_bab], '12.6' => [:birth_bahaullah] },
273
+ 300 => { '13.5' => [:birth_bab], '13.6' => [:birth_bahaullah] },
274
+ 301 => { '12.14' => [:birth_bab], '12.15' => [:birth_bahaullah] },
275
+ 302 => { '12.3' => [:birth_bab], '12.4' => [:birth_bahaullah] },
276
+ 303 => { '13.2' => [:birth_bab], '13.3' => [:birth_bahaullah] },
277
+ 304 => { '12.11' => [:birth_bab], '12.12' => [:birth_bahaullah] },
278
+ 305 => { '13.10' => [:birth_bab], '13.11' => [:birth_bahaullah] },
279
+ 306 => { '12.18' => [:birth_bab], '12.19' => [:birth_bahaullah] }
280
+ }
281
+
282
+ def initialize(year, month, day)
283
+ @year = year
284
+ @month = month
285
+ @day = day
286
+ end
287
+
288
+ def occasions
289
+ create_occasions_classes_from occasions_hashes
290
+ end
291
+
292
+ private
293
+
294
+ def create_occasions_classes_from(hashes_array)
295
+ hashes_array.map! { |opts_hash| Occasion.new(opts_hash) }
296
+ end
297
+
298
+ def occasions_hashes
299
+ hashes_array = []
300
+ each_ids { |ids |
301
+ if ids
302
+ hashes_array += OCCASIONS.values_at(*ids)
303
+ end
304
+ }
305
+ hashes_array
306
+ end
307
+
308
+ def each_ids
309
+ key = "#{@month}.#{@day}"
310
+ yield DATES[key]
311
+ if @year < 172
312
+ yield DATES_BEFORE_172[key]
313
+ else
314
+ yield DATES_AFTER_172[key]
315
+ yield DATES_LUNAR[@year][key]
316
+ end
317
+ end
318
+
319
+ end
320
+
321
+ end
@@ -0,0 +1,51 @@
1
+ module BahaiDate
2
+
3
+ class Weekday
4
+ TITLES = %w[Jalal Jamal Kamal Fidal Idal Istijlal Istiqlal]
5
+ TITLES_HTML = %w[Jalál Jamál Kamál Fiḍál ‘Idál Istijlál Istiqlál]
6
+ TITLES_EN = %w[Glory Beauty Perfection Grace Justice Majesty Independence]
7
+ ENGLISH_EQUIVALENTS = %w[Saturday Sunday Monday Tuesday Wednesday Thursday Friday]
8
+
9
+ attr_reader :number
10
+
11
+ def initialize(number_arg)
12
+ validate number_arg
13
+ @number = number_arg.to_i
14
+ end
15
+
16
+ def to_s
17
+ title
18
+ end
19
+
20
+ def title
21
+ TITLES[title_index]
22
+ end
23
+
24
+ def translation
25
+ TITLES_EN[title_index]
26
+ end
27
+
28
+ def html
29
+ TITLES_HTML[title_index]
30
+ end
31
+
32
+ def english_equivalent
33
+ ENGLISH_EQUIVALENTS[title_index]
34
+ end
35
+
36
+ private
37
+
38
+ def title_index
39
+ @number - 1
40
+ end
41
+
42
+ def validate(number_arg)
43
+ number = number_arg.to_i
44
+ if (number < 1 || number > 7)
45
+ raise ArgumentError, "'#{number}' is not a valid weekday. Please use 1 to 7."
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -0,0 +1,66 @@
1
+ require_relative 'month'
2
+
3
+ module BahaiDate
4
+
5
+ class Year
6
+ TITLES = %w[Alif Ba Ab Dal Bab Vav Abad Jad Baha Hubb Bahhaj Javab Ahad Vahhab Vidad Badi Bahi Abha Vahid]
7
+ TITLES_HTML = %w[Alif Bá’ Ab Dál Báb Váv Abad Jád Bahá Ḥubb Bahháj Javáb Aḥad Vahháb Vidád Badí‘ Bahí Abhá Váḥid]
8
+ TITLES_EN = %w[A B Father D Gate V Eternity Generosity Splendour Love Delightful Answer Single Bountiful Affection Beginning Luminous Most Luminous Unity]
9
+
10
+ attr_reader :bahai_era, :number, :vahid, :kull_i_shay, :months
11
+
12
+ def initialize(number_arg)
13
+ validate number_arg
14
+ @bahai_era = number_arg.to_i
15
+ calculate_number_vahid_and_kull_i_shay
16
+ @months = {}
17
+ end
18
+
19
+ def to_s
20
+ @bahai_era.to_s
21
+ end
22
+
23
+ def title
24
+ TITLES[title_index]
25
+ end
26
+
27
+ def translation
28
+ TITLES_EN[title_index]
29
+ end
30
+
31
+ def html
32
+ TITLES_HTML[title_index]
33
+ end
34
+
35
+ def set_month(month_number)
36
+ if @months[month_number]
37
+ @months[month_number]
38
+ else
39
+ @months[month_number] = Month.new(month_number)
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def title_index
46
+ @number - 1
47
+ end
48
+
49
+ def validate(number_arg)
50
+ number = number_arg.to_i
51
+ if (number < 1)
52
+ raise ArgumentError, "'#{number}' is not a valid year. Please use a number greater than or equal to 1."
53
+ end
54
+ end
55
+
56
+ def calculate_number_vahid_and_kull_i_shay
57
+ @vahid, @number = (@bahai_era - 1).divmod(19)
58
+ @kull_i_shay, @vahid = @vahid.divmod(19)
59
+ @number += 1
60
+ @vahid += 1
61
+ @kull_i_shay += 1
62
+ end
63
+
64
+ end
65
+
66
+ end
@@ -0,0 +1,32 @@
1
+ require_relative 'year'
2
+ require_relative 'bahai_date'
3
+
4
+ module BahaiDate
5
+
6
+ class YearCalendar < Year
7
+
8
+ def initialize(number_arg)
9
+ super
10
+ populate_calendar
11
+ end
12
+
13
+ private
14
+
15
+ def populate_calendar
16
+ date = BahaiDate.new(year: @bahai_era, month: 1, day: 1)
17
+ while date.year.bahai_era == @bahai_era do
18
+ add_to_calendar date
19
+ date.next_day!
20
+ end
21
+ end
22
+
23
+ def add_to_calendar(date)
24
+ month = set_month date.month.number
25
+ day = month.set_day date.day.number
26
+ day.set_weekday date.weekday
27
+ day.set_occasions date.occasions
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,23 @@
1
+ require 'date'
2
+
3
+ module BahaiDate
4
+
5
+ class YearData
6
+
7
+ # valid up to 2148
8
+ LEAP_YEARS = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, 168, 174, 178, 182, 187, 191, 195, 199, 203, 207, 211, 216, 220, 224, 228, 232, 236, 240, 244, 249, 253, 257, 261, 265, 269, 273, 277, 282, 286, 290, 294, 298, 302]
9
+ # valid up to 2149
10
+ NAWRUZ_DAYS = {2015=>21, 2016=>20, 2017=>20, 2018=>21, 2019=>21, 2020=>20, 2021=>20, 2022=>21, 2023=>21, 2024=>20, 2025=>20, 2026=>21, 2027=>21, 2028=>20, 2029=>20, 2030=>20, 2031=>21, 2032=>20, 2033=>20, 2034=>20, 2035=>21, 2036=>20, 2037=>20, 2038=>20, 2039=>21, 2040=>20, 2041=>20, 2042=>20, 2043=>21, 2044=>20, 2045=>20, 2046=>20, 2047=>21, 2048=>20, 2049=>20, 2050=>20, 2051=>21, 2052=>20, 2053=>20, 2054=>20, 2055=>21, 2056=>20, 2057=>20, 2058=>20, 2059=>20, 2060=>20, 2061=>20, 2062=>20, 2063=>20, 2064=>20, 2065=>20, 2066=>20, 2067=>20, 2068=>20, 2069=>20, 2070=>20, 2071=>20, 2072=>20, 2073=>20, 2074=>20, 2075=>20, 2076=>20, 2077=>20, 2078=>20, 2079=>20, 2080=>20, 2081=>20, 2082=>20, 2083=>20, 2084=>20, 2085=>20, 2086=>20, 2087=>20, 2088=>20, 2089=>20, 2090=>20, 2091=>20, 2092=>19, 2093=>20, 2094=>20, 2095=>20, 2096=>19, 2097=>20, 2098=>20, 2099=>20, 2100=>20, 2101=>21, 2102=>21, 2103=>21, 2104=>20, 2105=>21, 2106=>21, 2107=>21, 2108=>20, 2109=>21, 2110=>21, 2111=>21, 2112=>20, 2113=>21, 2114=>21, 2115=>21, 2116=>20, 2117=>21, 2118=>21, 2119=>21, 2120=>20, 2121=>21, 2122=>21, 2123=>21, 2124=>20, 2125=>20, 2126=>21, 2127=>21, 2128=>20, 2129=>20, 2130=>21, 2131=>21, 2132=>20, 2133=>20, 2134=>21, 2135=>21, 2136=>20, 2137=>20, 2138=>21, 2139=>21, 2140=>20, 2141=>20, 2142=>21, 2143=>21, 2144=>20, 2145=>20, 2146=>21, 2147=>21, 2148=>20, 2149=>20}
11
+
12
+ def self.nawruz_for(year)
13
+ nawruz_day = year < 2015 ? 21 : NAWRUZ_DAYS[year]
14
+ Date.new(year, 3, nawruz_day)
15
+ end
16
+
17
+ def self.is_leap?(year)
18
+ LEAP_YEARS.include? year
19
+ end
20
+
21
+ end
22
+
23
+ end