bahai_date 1.2.0 → 1.3.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.
- checksums.yaml +4 -4
- data/README.md +13 -4
- data/lib/bahai_date.rb +11 -11
- data/lib/bahai_date/bahai_date.rb +9 -7
- data/lib/bahai_date/logic.rb +114 -0
- data/lib/bahai_date/month.rb +1 -1
- data/lib/bahai_date/occasion_factory.rb +12 -141
- data/lib/bahai_date/version.rb +1 -1
- data/spec/bahai_date/bahai_date_spec.rb +0 -8
- data/spec/bahai_date/day_spec.rb +0 -2
- data/spec/bahai_date/logic_spec.rb +20 -0
- data/spec/bahai_date/month_spec.rb +0 -2
- data/spec/bahai_date/occasion_factory_spec.rb +9 -6
- data/spec/bahai_date/occasion_spec.rb +5 -7
- data/spec/bahai_date/weekday_spec.rb +0 -1
- data/spec/bahai_date/year_calendar_spec.rb +0 -2
- data/spec/bahai_date/year_spec.rb +0 -1
- data/spec/spec_helper.rb +3 -1
- metadata +65 -8
- data/lib/bahai_date/year_data.rb +0 -17
- data/spec/bahai_date/year_data_spec.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e66f7ba2f2bf6e012d017503403d74ba8b81b9f
|
4
|
+
data.tar.gz: 17455cd3d5ab3ee6cda1e8eca220b63727a9b744
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8296ccb87541543b41f0d43cf38d597b13d83a9d3df2e2bd8f7d7d8c60632018391e166b731e3a8403b2b1484cde593d4d87eb3bf1f7b782bc90547c24e6bf09
|
7
|
+
data.tar.gz: 763879ca381dd8ad9424419326cb620def1fed5cd3b1b4f11a3fa7c74c39a45778cdac082a8f58ab00d95c6b0658a2b755c64ab3da7ca71a4e5b66909078a014
|
data/README.md
CHANGED
@@ -16,6 +16,15 @@ The calendar begins on the vernal equinox, normally on the 20th or 21st of March
|
|
16
16
|
More information about this calendar is on the [Wikipedia entry](http://en.wikipedia.org/wiki/Bah%C3%A1'%C3%AD_calendar).
|
17
17
|
|
18
18
|
|
19
|
+
Calculations
|
20
|
+
------------
|
21
|
+
The source of the algorithms used to determine the vernal equinox and lunar
|
22
|
+
phases is the book [*Astronomical Algorithms*](http://www.willbell.com/math/mc1.htm) by Jean Meeus, which has become an authority on this subject in computer science circles (for example, [NASA uses it](http://eclipse.gsfc.nasa.gov/phase/phasecat.html)). Some of the algorithms in the book have been implemented in the *astro-algo* ruby
|
23
|
+
gem (https://rubygems.org/gems/astro-algo), which we use here.
|
24
|
+
|
25
|
+
Also, the ruby gem *sunrise* (https://rubygems.org/gems/RubySunrise) is widely used to determine the time for sunrise/sunset at a given location, and we use it here.
|
26
|
+
|
27
|
+
|
19
28
|
Functionality
|
20
29
|
-------------
|
21
30
|
A BahaiDate instance can be created either from a Gregorian date or supplying the year, month and day in the Baha'i calendar.
|
@@ -41,13 +50,13 @@ Example Usage
|
|
41
50
|
-------------
|
42
51
|
Creating an instance:
|
43
52
|
```ruby
|
44
|
-
require
|
53
|
+
require 'bahai_date'
|
45
54
|
|
46
|
-
today = BahaiDate.new(date: Date.today)
|
55
|
+
today = BahaiDate::BahaiDate.new(date: Date.today)
|
47
56
|
|
48
57
|
#or
|
49
58
|
|
50
|
-
nawruz = BahaiDate.new(year: 171, month: 1, day: 1)
|
59
|
+
nawruz = BahaiDate::BahaiDate.new(year: 171, month: 1, day: 1)
|
51
60
|
```
|
52
61
|
|
53
62
|
Attributes:
|
@@ -65,7 +74,7 @@ gregorian_date: 2014-10-04
|
|
65
74
|
|
66
75
|
Calendar:
|
67
76
|
```ruby
|
68
|
-
calendar = YearCalendar.new(171)
|
77
|
+
calendar = BahaiDate::YearCalendar.new(171)
|
69
78
|
puts "Year: " + calendar.bahai_era.to_s
|
70
79
|
puts "Month 1:" + calendar.months[1].title
|
71
80
|
puts " Day 1 in Month 1:" + calendar.months[1].days[1].title
|
data/lib/bahai_date.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
1
|
+
require 'date'
|
2
|
+
require 'bahai_date/version'
|
3
|
+
require 'bahai_date/logic'
|
4
|
+
require 'bahai_date/bahai_date'
|
5
|
+
require 'bahai_date/year'
|
6
|
+
require 'bahai_date/month'
|
7
|
+
require 'bahai_date/day'
|
8
|
+
require 'bahai_date/weekday'
|
9
|
+
require 'bahai_date/occasion'
|
10
|
+
require 'bahai_date/occasion_factory'
|
11
|
+
require 'bahai_date/year_calendar'
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module BahaiDate
|
2
2
|
class BahaiDate
|
3
|
-
|
4
3
|
AYYAM_I_HA = -1
|
5
4
|
|
6
|
-
attr_reader :weekday, :day, :month, :year, :gregorian_date
|
5
|
+
attr_reader :weekday, :day, :month, :year, :gregorian_date
|
7
6
|
|
8
7
|
def initialize(params)
|
9
8
|
if params[:date]
|
@@ -22,7 +21,10 @@ module BahaiDate
|
|
22
21
|
fail ArgumentError, 'Invalid arguments. Use a hash with :date or with :year, :month, and :day.'
|
23
22
|
end
|
24
23
|
@weekday = Weekday.new(weekday_from_gregorian)
|
25
|
-
|
24
|
+
end
|
25
|
+
|
26
|
+
def occasions
|
27
|
+
OccasionFactory.new(@year.bahai_era, @month.number, @day.number).occasions
|
26
28
|
end
|
27
29
|
|
28
30
|
def to_s
|
@@ -44,24 +46,24 @@ module BahaiDate
|
|
44
46
|
end
|
45
47
|
|
46
48
|
def ayyam_i_ha_days(year = @year.bahai_era)
|
47
|
-
|
49
|
+
Logic.leap?(year) ? 5 : 4
|
48
50
|
end
|
49
51
|
|
50
52
|
def to_gregorian
|
51
53
|
year_gregorian = @year.bahai_era + 1844 - 1
|
52
|
-
nawruz =
|
54
|
+
nawruz = Logic.nawruz_for(year_gregorian)
|
53
55
|
nawruz + days_from_nawruz
|
54
56
|
end
|
55
57
|
|
56
58
|
def from_gregorian
|
57
|
-
nawruz =
|
59
|
+
nawruz = Logic.nawruz_for(@gregorian_date.year)
|
58
60
|
|
59
61
|
year = @gregorian_date.year - 1844
|
60
62
|
if @gregorian_date >= nawruz
|
61
63
|
year += 1
|
62
64
|
days = (@gregorian_date - nawruz).to_i
|
63
65
|
else
|
64
|
-
days = (@gregorian_date -
|
66
|
+
days = (@gregorian_date - Logic.nawruz_for(@gregorian_date.year - 1)).to_i
|
65
67
|
end
|
66
68
|
|
67
69
|
# determine day and month, taking into account ayyam-i-ha
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'tzinfo'
|
3
|
+
require 'solareventcalculator'
|
4
|
+
require 'astro-algo'
|
5
|
+
|
6
|
+
module BahaiDate
|
7
|
+
class Logic
|
8
|
+
####
|
9
|
+
# Note: This class uses dates in the Gregorian calendar internally, as they
|
10
|
+
# are used by the libraries which determine leap years, the spring equinox
|
11
|
+
# and lunar phases.
|
12
|
+
####
|
13
|
+
|
14
|
+
# *** Latitude and longitude for Tehran, Iran ***
|
15
|
+
# Source: http://mynasadata.larc.nasa.gov/latitudelongitude-finder/
|
16
|
+
# Latitude: 35° 41' 45.9996", Longitude: 51° 25' 23.0016"
|
17
|
+
# Converted to decimal using:
|
18
|
+
# http://transition.fcc.gov/mb/audio/bickel/DDDMMSS-decimal.html
|
19
|
+
TEHRAN_LAT = BigDecimal.new('35.696111')
|
20
|
+
TEHRAN_LONG = BigDecimal.new('51.423056')
|
21
|
+
|
22
|
+
# *** Azimuth (for determining sunset times) ***
|
23
|
+
# Source: http://www.timeanddate.com/astronomy/about-sun-calculator.html
|
24
|
+
# "Technically, sunrise and sunset are calculated based on the true geocentric position of the Sun at 90°50' from the zenith position (directly above the observer)."
|
25
|
+
# Converted to decimal using:
|
26
|
+
# http://www.satsig.net/degrees-minutes-seconds-calculator.htm
|
27
|
+
AZIMUTH = 90.833333
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
@tz = TZInfo::Timezone.get('Asia/Tehran')
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.nawruz_for(year)
|
34
|
+
new.nawruz_date year
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.leap?(year_bahai_era)
|
38
|
+
new.leap? year_bahai_era
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.twin_holy_days_date(year_bahai_era)
|
42
|
+
new.twin_holy_days_for year_bahai_era
|
43
|
+
end
|
44
|
+
|
45
|
+
def nawruz_date(year)
|
46
|
+
if year < 2015
|
47
|
+
Date.new(year, 3, 21)
|
48
|
+
else
|
49
|
+
spring_equinox_in_tehran(year)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def nawruz_time(year)
|
54
|
+
sunset_time_for(nawruz_date(year))
|
55
|
+
end
|
56
|
+
|
57
|
+
def sunset_time_for(date)
|
58
|
+
calc = SolarEventCalculator.new(date, TEHRAN_LAT, TEHRAN_LONG)
|
59
|
+
sunset_time = calc.compute_utc_solar_event(AZIMUTH, false)
|
60
|
+
localize(sunset_time.utc)
|
61
|
+
end
|
62
|
+
|
63
|
+
def spring_equinox_in_tehran(year)
|
64
|
+
increment_if_after_sunset localize(Astro.date_of_vernal_equinox(year).to_utc)
|
65
|
+
end
|
66
|
+
|
67
|
+
def twin_holy_days_for(year_bahai_era)
|
68
|
+
gregorian_year = bahai_era_to_gregorian_year(year_bahai_era)
|
69
|
+
increment_if_after_sunset(eighth_new_moon_for(gregorian_year)) + 1
|
70
|
+
end
|
71
|
+
|
72
|
+
def eighth_new_moon_for(year)
|
73
|
+
nawruz = nawruz_time(year)
|
74
|
+
lunation = Astro.first_lunation_of_year(year)
|
75
|
+
lunation += 1 while new_moon(lunation) <= nawruz
|
76
|
+
new_moon(lunation + 7)
|
77
|
+
end
|
78
|
+
|
79
|
+
def new_moon(lunation)
|
80
|
+
localize(Astro.date_of_moon(lunation, Astro::PhaseNew).to_utc)
|
81
|
+
end
|
82
|
+
|
83
|
+
def leap?(year_bahai_era)
|
84
|
+
gregorian_year = bahai_era_to_gregorian_year(year_bahai_era)
|
85
|
+
if gregorian_year < 2015
|
86
|
+
Date.leap? gregorian_year + 1
|
87
|
+
else
|
88
|
+
leap_bahai_era? gregorian_year
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def leap_bahai_era?(year)
|
93
|
+
(nawruz_date(year + 1) - nawruz_date(year)) == 366
|
94
|
+
end
|
95
|
+
|
96
|
+
def bahai_era_to_gregorian_year(year)
|
97
|
+
1843 + year
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def localize(time)
|
103
|
+
(@tz.utc_to_local(time)).to_time
|
104
|
+
end
|
105
|
+
|
106
|
+
def increment_if_after_sunset(time)
|
107
|
+
date = time.to_date
|
108
|
+
if time > sunset_time_for(date)
|
109
|
+
date += 1
|
110
|
+
end
|
111
|
+
date
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
data/lib/bahai_date/month.rb
CHANGED
@@ -45,7 +45,7 @@ module BahaiDate
|
|
45
45
|
|
46
46
|
def validate(number_arg)
|
47
47
|
number = number_arg.to_i
|
48
|
-
return if (
|
48
|
+
return if (1..19).include?(number) || number == -1
|
49
49
|
fail ArgumentError, "'#{number}' is not a valid month. Please use 1 to 19 or -1 for Ayyam-i-Ha."
|
50
50
|
end
|
51
51
|
end
|
@@ -137,144 +137,6 @@ module BahaiDate
|
|
137
137
|
'6.17' => [:martyrdom_bab]
|
138
138
|
}
|
139
139
|
|
140
|
-
DATES_LUNAR = {
|
141
|
-
172 => { '13.10' => [:birth_bab], '13.11' => [:birth_bahaullah] },
|
142
|
-
173 => { '12.18' => [:birth_bab], '12.19' => [:birth_bahaullah] },
|
143
|
-
174 => { '12.7' => [:birth_bab], '12.8' => [:birth_bahaullah] },
|
144
|
-
175 => { '13.6' => [:birth_bab], '13.7' => [:birth_bahaullah] },
|
145
|
-
176 => { '12.14' => [:birth_bab], '12.15' => [:birth_bahaullah] },
|
146
|
-
177 => { '12.4' => [:birth_bab], '12.5' => [:birth_bahaullah] },
|
147
|
-
178 => { '13.4' => [:birth_bab], '13.5' => [:birth_bahaullah] },
|
148
|
-
179 => { '12.11' => [:birth_bab], '12.12' => [:birth_bahaullah] },
|
149
|
-
180 => { '12.1' => [:birth_bab], '12.2' => [:birth_bahaullah] },
|
150
|
-
181 => { '12.19' => [:birth_bab], '13.1' => [:birth_bahaullah] },
|
151
|
-
182 => { '12.8' => [:birth_bab], '12.9' => [:birth_bahaullah] },
|
152
|
-
183 => { '13.7' => [:birth_bab], '13.8' => [:birth_bahaullah] },
|
153
|
-
184 => { '12.15' => [:birth_bab], '12.16' => [:birth_bahaullah] },
|
154
|
-
185 => { '12.5' => [:birth_bab], '12.6' => [:birth_bahaullah] },
|
155
|
-
186 => { '13.5' => [:birth_bab], '13.6' => [:birth_bahaullah] },
|
156
|
-
187 => { '12.14' => [:birth_bab], '12.15' => [:birth_bahaullah] },
|
157
|
-
188 => { '12.2' => [:birth_bab], '12.3' => [:birth_bahaullah] },
|
158
|
-
189 => { '13.2' => [:birth_bab], '13.3' => [:birth_bahaullah] },
|
159
|
-
190 => { '12.10' => [:birth_bab], '12.11' => [:birth_bahaullah] },
|
160
|
-
191 => { '13.10' => [:birth_bab], '13.11' => [:birth_bahaullah] },
|
161
|
-
192 => { '12.17' => [:birth_bab], '12.18' => [:birth_bahaullah] },
|
162
|
-
193 => { '12.6' => [:birth_bab], '12.7' => [:birth_bahaullah] },
|
163
|
-
194 => { '13.6' => [:birth_bab], '13.7' => [:birth_bahaullah] },
|
164
|
-
195 => { '12.15' => [:birth_bab], '12.16' => [:birth_bahaullah] },
|
165
|
-
196 => { '12.4' => [:birth_bab], '12.5' => [:birth_bahaullah] },
|
166
|
-
197 => { '13.4' => [:birth_bab], '13.5' => [:birth_bahaullah] },
|
167
|
-
198 => { '12.12' => [:birth_bab], '12.13' => [:birth_bahaullah] },
|
168
|
-
199 => { '12.1' => [:birth_bab], '12.2' => [:birth_bahaullah] },
|
169
|
-
200 => { '12.19' => [:birth_bab], '13.1' => [:birth_bahaullah] },
|
170
|
-
201 => { '12.8' => [:birth_bab], '12.9' => [:birth_bahaullah] },
|
171
|
-
202 => { '13.8' => [:birth_bab], '13.9' => [:birth_bahaullah] },
|
172
|
-
203 => { '12.16' => [:birth_bab], '12.17' => [:birth_bahaullah] },
|
173
|
-
204 => { '12.5' => [:birth_bab], '12.6' => [:birth_bahaullah] },
|
174
|
-
205 => { '13.5' => [:birth_bab], '13.6' => [:birth_bahaullah] },
|
175
|
-
206 => { '12.14' => [:birth_bab], '12.15' => [:birth_bahaullah] },
|
176
|
-
207 => { '12.3' => [:birth_bab], '12.4' => [:birth_bahaullah] },
|
177
|
-
208 => { '13.2' => [:birth_bab], '13.3' => [:birth_bahaullah] },
|
178
|
-
209 => { '12.10' => [:birth_bab], '12.11' => [:birth_bahaullah] },
|
179
|
-
210 => { '13.9' => [:birth_bab], '13.10' => [:birth_bahaullah] },
|
180
|
-
211 => { '12.18' => [:birth_bab], '12.19' => [:birth_bahaullah] },
|
181
|
-
212 => { '12.6' => [:birth_bab], '12.7' => [:birth_bahaullah] },
|
182
|
-
213 => { '13.6' => [:birth_bab], '13.7' => [:birth_bahaullah] },
|
183
|
-
214 => { '12.15' => [:birth_bab], '12.16' => [:birth_bahaullah] },
|
184
|
-
215 => { '12.4' => [:birth_bab], '12.5' => [:birth_bahaullah] },
|
185
|
-
216 => { '13.4' => [:birth_bab], '13.5' => [:birth_bahaullah] },
|
186
|
-
217 => { '12.11' => [:birth_bab], '12.12' => [:birth_bahaullah] },
|
187
|
-
218 => { '11.19' => [:birth_bab], '12.1' => [:birth_bahaullah] },
|
188
|
-
219 => { '12.19' => [:birth_bab], '13.1' => [:birth_bahaullah] },
|
189
|
-
220 => { '12.9' => [:birth_bab], '12.10' => [:birth_bahaullah] },
|
190
|
-
221 => { '13.8' => [:birth_bab], '13.9' => [:birth_bahaullah] },
|
191
|
-
222 => { '12.16' => [:birth_bab], '12.17' => [:birth_bahaullah] },
|
192
|
-
223 => { '12.6' => [:birth_bab], '12.7' => [:birth_bahaullah] },
|
193
|
-
224 => { '13.6' => [:birth_bab], '13.7' => [:birth_bahaullah] },
|
194
|
-
225 => { '12.13' => [:birth_bab], '12.14' => [:birth_bahaullah] },
|
195
|
-
226 => { '12.2' => [:birth_bab], '12.3' => [:birth_bahaullah] },
|
196
|
-
227 => { '13.2' => [:birth_bab], '13.3' => [:birth_bahaullah] },
|
197
|
-
228 => { '12.10' => [:birth_bab], '12.11' => [:birth_bahaullah] },
|
198
|
-
229 => { '13.9' => [:birth_bab], '13.10' => [:birth_bahaullah] },
|
199
|
-
230 => { '12.18' => [:birth_bab], '12.19' => [:birth_bahaullah] },
|
200
|
-
231 => { '12.7' => [:birth_bab], '12.8' => [:birth_bahaullah] },
|
201
|
-
232 => { '13.7' => [:birth_bab], '13.8' => [:birth_bahaullah] },
|
202
|
-
233 => { '12.15' => [:birth_bab], '12.16' => [:birth_bahaullah] },
|
203
|
-
234 => { '12.4' => [:birth_bab], '12.5' => [:birth_bahaullah] },
|
204
|
-
235 => { '13.4' => [:birth_bab], '13.5' => [:birth_bahaullah] },
|
205
|
-
236 => { '12.12' => [:birth_bab], '12.13' => [:birth_bahaullah] },
|
206
|
-
237 => { '11.19' => [:birth_bab], '12.1' => [:birth_bahaullah] },
|
207
|
-
238 => { '12.19' => [:birth_bab], '13.1' => [:birth_bahaullah] },
|
208
|
-
239 => { '12.9' => [:birth_bab], '12.10' => [:birth_bahaullah] },
|
209
|
-
240 => { '13.9' => [:birth_bab], '13.10' => [:birth_bahaullah] },
|
210
|
-
241 => { '12.16' => [:birth_bab], '12.17' => [:birth_bahaullah] },
|
211
|
-
242 => { '12.6' => [:birth_bab], '12.7' => [:birth_bahaullah] },
|
212
|
-
243 => { '13.5' => [:birth_bab], '13.6' => [:birth_bahaullah] },
|
213
|
-
244 => { '12.13' => [:birth_bab], '12.14' => [:birth_bahaullah] },
|
214
|
-
245 => { '12.2' => [:birth_bab], '12.3' => [:birth_bahaullah] },
|
215
|
-
246 => { '13.1' => [:birth_bab], '13.2' => [:birth_bahaullah] },
|
216
|
-
247 => { '12.10' => [:birth_bab], '12.11' => [:birth_bahaullah] },
|
217
|
-
248 => { '13.10' => [:birth_bab], '13.11' => [:birth_bahaullah] },
|
218
|
-
249 => { '12.19' => [:birth_bab], '13.1' => [:birth_bahaullah] },
|
219
|
-
250 => { '12.7' => [:birth_bab], '12.8' => [:birth_bahaullah] },
|
220
|
-
251 => { '13.7' => [:birth_bab], '13.8' => [:birth_bahaullah] },
|
221
|
-
252 => { '12.15' => [:birth_bab], '12.16' => [:birth_bahaullah] },
|
222
|
-
253 => { '12.4' => [:birth_bab], '12.5' => [:birth_bahaullah] },
|
223
|
-
254 => { '13.3' => [:birth_bab], '13.4' => [:birth_bahaullah] },
|
224
|
-
255 => { '12.11' => [:birth_bab], '12.12' => [:birth_bahaullah] },
|
225
|
-
256 => { '12.1' => [:birth_bab], '12.2' => [:birth_bahaullah] },
|
226
|
-
257 => { '13.1' => [:birth_bab], '13.2' => [:birth_bahaullah] },
|
227
|
-
258 => { '12.9' => [:birth_bab], '12.10' => [:birth_bahaullah] },
|
228
|
-
259 => { '13.9' => [:birth_bab], '13.10' => [:birth_bahaullah] },
|
229
|
-
260 => { '12.17' => [:birth_bab], '12.18' => [:birth_bahaullah] },
|
230
|
-
261 => { '12.6' => [:birth_bab], '12.7' => [:birth_bahaullah] },
|
231
|
-
262 => { '13.5' => [:birth_bab], '13.6' => [:birth_bahaullah] },
|
232
|
-
263 => { '12.13' => [:birth_bab], '12.14' => [:birth_bahaullah] },
|
233
|
-
264 => { '12.2' => [:birth_bab], '12.3' => [:birth_bahaullah] },
|
234
|
-
265 => { '13.2' => [:birth_bab], '13.3' => [:birth_bahaullah] },
|
235
|
-
266 => { '12.10' => [:birth_bab], '12.11' => [:birth_bahaullah] },
|
236
|
-
267 => { '13.10' => [:birth_bab], '13.11' => [:birth_bahaullah] },
|
237
|
-
268 => { '12.19' => [:birth_bab], '13.1' => [:birth_bahaullah] },
|
238
|
-
269 => { '12.8' => [:birth_bab], '12.9' => [:birth_bahaullah] },
|
239
|
-
270 => { '13.7' => [:birth_bab], '13.8' => [:birth_bahaullah] },
|
240
|
-
271 => { '12.15' => [:birth_bab], '12.16' => [:birth_bahaullah] },
|
241
|
-
272 => { '12.4' => [:birth_bab], '12.5' => [:birth_bahaullah] },
|
242
|
-
273 => { '13.4' => [:birth_bab], '13.5' => [:birth_bahaullah] },
|
243
|
-
274 => { '12.11' => [:birth_bab], '12.12' => [:birth_bahaullah] },
|
244
|
-
275 => { '12.1' => [:birth_bab], '12.2' => [:birth_bahaullah] },
|
245
|
-
276 => { '13.1' => [:birth_bab], '13.2' => [:birth_bahaullah] },
|
246
|
-
277 => { '12.9' => [:birth_bab], '12.10' => [:birth_bahaullah] },
|
247
|
-
278 => { '13.8' => [:birth_bab], '13.9' => [:birth_bahaullah] },
|
248
|
-
279 => { '12.16' => [:birth_bab], '12.17' => [:birth_bahaullah] },
|
249
|
-
280 => { '12.5' => [:birth_bab], '12.6' => [:birth_bahaullah] },
|
250
|
-
281 => { '13.5' => [:birth_bab], '13.6' => [:birth_bahaullah] },
|
251
|
-
282 => { '12.14' => [:birth_bab], '12.15' => [:birth_bahaullah] },
|
252
|
-
283 => { '12.2' => [:birth_bab], '12.3' => [:birth_bahaullah] },
|
253
|
-
284 => { '13.2' => [:birth_bab], '13.3' => [:birth_bahaullah] },
|
254
|
-
285 => { '12.11' => [:birth_bab], '12.12' => [:birth_bahaullah] },
|
255
|
-
286 => { '13.11' => [:birth_bab], '13.12' => [:birth_bahaullah] },
|
256
|
-
287 => { '12.18' => [:birth_bab], '12.19' => [:birth_bahaullah] },
|
257
|
-
288 => { '12.7' => [:birth_bab], '12.8' => [:birth_bahaullah] },
|
258
|
-
289 => { '13.7' => [:birth_bab], '13.8' => [:birth_bahaullah] },
|
259
|
-
290 => { '12.15' => [:birth_bab], '12.16' => [:birth_bahaullah] },
|
260
|
-
291 => { '12.4' => [:birth_bab], '12.5' => [:birth_bahaullah] },
|
261
|
-
292 => { '13.4' => [:birth_bab], '13.5' => [:birth_bahaullah] },
|
262
|
-
293 => { '12.12' => [:birth_bab], '12.13' => [:birth_bahaullah] },
|
263
|
-
294 => { '12.2' => [:birth_bab], '12.3' => [:birth_bahaullah] },
|
264
|
-
295 => { '13.1' => [:birth_bab], '13.2' => [:birth_bahaullah] },
|
265
|
-
296 => { '12.9' => [:birth_bab], '12.10' => [:birth_bahaullah] },
|
266
|
-
297 => { '13.9' => [:birth_bab], '13.10' => [:birth_bahaullah] },
|
267
|
-
298 => { '12.17' => [:birth_bab], '12.18' => [:birth_bahaullah] },
|
268
|
-
299 => { '12.5' => [:birth_bab], '12.6' => [:birth_bahaullah] },
|
269
|
-
300 => { '13.5' => [:birth_bab], '13.6' => [:birth_bahaullah] },
|
270
|
-
301 => { '12.14' => [:birth_bab], '12.15' => [:birth_bahaullah] },
|
271
|
-
302 => { '12.3' => [:birth_bab], '12.4' => [:birth_bahaullah] },
|
272
|
-
303 => { '13.2' => [:birth_bab], '13.3' => [:birth_bahaullah] },
|
273
|
-
304 => { '12.11' => [:birth_bab], '12.12' => [:birth_bahaullah] },
|
274
|
-
305 => { '13.10' => [:birth_bab], '13.11' => [:birth_bahaullah] },
|
275
|
-
306 => { '12.18' => [:birth_bab], '12.19' => [:birth_bahaullah] }
|
276
|
-
}
|
277
|
-
|
278
140
|
def initialize(year, month, day)
|
279
141
|
@year = year
|
280
142
|
@month = month
|
@@ -289,9 +151,9 @@ module BahaiDate
|
|
289
151
|
if year < 172
|
290
152
|
all_dates = DATES.merge(DATES_BEFORE_172)
|
291
153
|
else
|
292
|
-
all_dates = DATES.merge(DATES_AFTER_172).merge(
|
154
|
+
all_dates = DATES.merge(DATES_AFTER_172).merge(dates_lunar(year))
|
293
155
|
end
|
294
|
-
all_dates.find{ |
|
156
|
+
all_dates.find { |_key, array| array.include? occasion }.first
|
295
157
|
end
|
296
158
|
|
297
159
|
private
|
@@ -316,8 +178,17 @@ module BahaiDate
|
|
316
178
|
yield DATES_BEFORE_172[key]
|
317
179
|
else
|
318
180
|
yield DATES_AFTER_172[key]
|
319
|
-
yield
|
181
|
+
yield (self.class.dates_lunar(@year))[key]
|
320
182
|
end
|
321
183
|
end
|
184
|
+
|
185
|
+
def self.dates_lunar(year)
|
186
|
+
twin = Logic.twin_holy_days_date year
|
187
|
+
birth_bab = BahaiDate.new(date: twin)
|
188
|
+
birth_bab_string = "#{birth_bab.month.number}.#{birth_bab.day.number}"
|
189
|
+
birth_bahaullah = BahaiDate.new(date: twin + 1)
|
190
|
+
birth_bahaullah_string = "#{birth_bahaullah.month.number}.#{birth_bahaullah.day.number}"
|
191
|
+
{ birth_bab_string => [:birth_bab], birth_bahaullah_string => [:birth_bahaullah] }
|
192
|
+
end
|
322
193
|
end
|
323
194
|
end
|
data/lib/bahai_date/version.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module BahaiDate
|
2
2
|
describe BahaiDate do
|
3
|
-
|
4
3
|
it 'can be created from a year, month and day' do
|
5
4
|
bahai_date = BahaiDate.new(year: 1, month: 1, day: 1)
|
6
5
|
|
@@ -20,7 +19,6 @@ module BahaiDate
|
|
20
19
|
end
|
21
20
|
|
22
21
|
context "when validating the Baha'i Era date" do
|
23
|
-
|
24
22
|
context 'year' do
|
25
23
|
it 'raises an error if less than 1' do
|
26
24
|
expect do
|
@@ -76,7 +74,6 @@ module BahaiDate
|
|
76
74
|
end
|
77
75
|
end
|
78
76
|
end
|
79
|
-
|
80
77
|
end
|
81
78
|
|
82
79
|
it 'exposes weekday, day, month, year and gregorian_date' do
|
@@ -90,7 +87,6 @@ module BahaiDate
|
|
90
87
|
end
|
91
88
|
|
92
89
|
context 'when converting to a gregorian date' do
|
93
|
-
|
94
90
|
it 'handles the first day of the calendar' do
|
95
91
|
bahai_date = BahaiDate.new(year: 1, month: 1, day: 1)
|
96
92
|
expect(bahai_date.gregorian_date).to eq(Date.new(1844, 3, 21))
|
@@ -134,11 +130,9 @@ module BahaiDate
|
|
134
130
|
expect(bahai_date.gregorian_date).to eq(Date.new(2013, 3, 1))
|
135
131
|
end
|
136
132
|
end
|
137
|
-
|
138
133
|
end
|
139
134
|
|
140
135
|
context 'when converting from gregorian date' do
|
141
|
-
|
142
136
|
it 'handles the first day of the calendar' do
|
143
137
|
bahai_date = BahaiDate.new(date: Date.new(1844, 3, 21))
|
144
138
|
expect(bahai_date.year.bahai_era).to be 1
|
@@ -198,7 +192,6 @@ module BahaiDate
|
|
198
192
|
expect(bahai_date.day.number).to be 4
|
199
193
|
end
|
200
194
|
end
|
201
|
-
|
202
195
|
end
|
203
196
|
|
204
197
|
it 'can get weekday from a gregorian date accurately' do
|
@@ -250,6 +243,5 @@ module BahaiDate
|
|
250
243
|
bahai_date.next_day!
|
251
244
|
expect(bahai_date.gregorian_date).to eq Date.new(1844, 3, 22)
|
252
245
|
end
|
253
|
-
|
254
246
|
end
|
255
247
|
end
|
data/spec/bahai_date/day_spec.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
module BahaiDate
|
2
2
|
describe Day do
|
3
|
-
|
4
3
|
it 'can be created given a number from 1 to 19' do
|
5
4
|
expect(Day.new(1)).to_not be_nil
|
6
5
|
expect(Day.new(19)).to_not be_nil
|
@@ -56,6 +55,5 @@ module BahaiDate
|
|
56
55
|
expect(day.occasions).to be occasions
|
57
56
|
end
|
58
57
|
end
|
59
|
-
|
60
58
|
end
|
61
59
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module BahaiDate
|
2
|
+
describe Logic do
|
3
|
+
it 'supplies a Date object for Naw Ruz of a given year' do
|
4
|
+
expect(Logic.nawruz_for(1844)).to eq(Date.new(1844, 3, 21))
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'determines whether a year is leap or not' do
|
8
|
+
expect(Logic.leap?(1)).to eq(false)
|
9
|
+
expect(Logic.leap?(4)).to eq(true)
|
10
|
+
expect(Logic.leap?(168)).to eq(true)
|
11
|
+
expect(Logic.leap?(171)).to eq(false)
|
12
|
+
expect(Logic.leap?(172)).to eq(false)
|
13
|
+
expect(Logic.leap?(173)).to eq(false)
|
14
|
+
expect(Logic.leap?(174)).to eq(true)
|
15
|
+
expect(Logic.leap?(175)).to eq(false)
|
16
|
+
expect(Logic.leap?(176)).to eq(false)
|
17
|
+
expect(Logic.leap?(177)).to eq(false)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module BahaiDate
|
2
2
|
describe OccasionFactory do
|
3
|
-
|
4
3
|
it 'can be created given a year, month, and day' do
|
5
4
|
occasion_factory = OccasionFactory.new(1, 1, 1)
|
6
5
|
expect(occasion_factory).not_to be_nil
|
@@ -61,6 +60,11 @@ module BahaiDate
|
|
61
60
|
occasions = OccasionFactory.new(1, 13, 9).occasions
|
62
61
|
expect(occasions.first.short_title).to eq "Birth of Baha'u'llah"
|
63
62
|
end
|
63
|
+
|
64
|
+
it 'can find the month and day for a given occasion on a given year' do
|
65
|
+
month_and_day = OccasionFactory.find(:birth_bab, 163)
|
66
|
+
expect(month_and_day).to eq '12.5'
|
67
|
+
end
|
64
68
|
end
|
65
69
|
|
66
70
|
context 'for dates after 172 B.E.' do
|
@@ -82,11 +86,10 @@ module BahaiDate
|
|
82
86
|
expect(occasions.first.short_title).to eq 'Birth of the Bab'
|
83
87
|
end
|
84
88
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
expect(month_and_day).to eq '12.18'
|
89
|
+
it 'can find the month and day for a given occasion on a given year' do
|
90
|
+
month_and_day = OccasionFactory.find(:birth_bab, 173)
|
91
|
+
expect(month_and_day).to eq '12.18'
|
92
|
+
end
|
90
93
|
end
|
91
94
|
end
|
92
95
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
module BahaiDate
|
2
2
|
describe Occasion do
|
3
|
-
|
4
3
|
subject(:occasion) do
|
5
4
|
Occasion.new(type: :ayyam_i_ha,
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
work_suspended: false,
|
6
|
+
title: 'Test title',
|
7
|
+
short_title: 'Test short title',
|
8
|
+
title_html: 'Test title html',
|
9
|
+
short_title_html: 'Test short title html ')
|
11
10
|
end
|
12
11
|
|
13
12
|
it 'can be created given an options hash' do
|
@@ -17,6 +16,5 @@ module BahaiDate
|
|
17
16
|
it 'exposes a work_suspended? method' do
|
18
17
|
expect(occasion.work_suspended?).to be false
|
19
18
|
end
|
20
|
-
|
21
19
|
end
|
22
20
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module BahaiDate
|
2
2
|
describe YearCalendar do
|
3
|
-
|
4
3
|
subject(:year_calendar) { YearCalendar.new(1) }
|
5
4
|
|
6
5
|
it 'can be created' do
|
@@ -36,6 +35,5 @@ module BahaiDate
|
|
36
35
|
day = year_calendar.months[1].days[1]
|
37
36
|
expect(day.occasions.size).to be 2
|
38
37
|
end
|
39
|
-
|
40
38
|
end
|
41
39
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bahai_date
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lessan Vaezi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tzinfo
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: RubySunrise
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: astro-algo
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
13
55
|
- !ruby/object:Gem::Dependency
|
14
56
|
name: rspec
|
15
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,7 +66,23 @@ dependencies:
|
|
24
66
|
- - "~>"
|
25
67
|
- !ruby/object:Gem::Version
|
26
68
|
version: '3'
|
27
|
-
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Provides functionality to convert between the Gregorian and Baha'i calendar,
|
84
|
+
as well as significant dates and occasions in the Baha'i calendar such as the new
|
85
|
+
year and holy days
|
28
86
|
email: lessan@gmail.com
|
29
87
|
executables: []
|
30
88
|
extensions: []
|
@@ -35,6 +93,7 @@ files:
|
|
35
93
|
- lib/bahai_date.rb
|
36
94
|
- lib/bahai_date/bahai_date.rb
|
37
95
|
- lib/bahai_date/day.rb
|
96
|
+
- lib/bahai_date/logic.rb
|
38
97
|
- lib/bahai_date/month.rb
|
39
98
|
- lib/bahai_date/occasion.rb
|
40
99
|
- lib/bahai_date/occasion_factory.rb
|
@@ -42,15 +101,14 @@ files:
|
|
42
101
|
- lib/bahai_date/weekday.rb
|
43
102
|
- lib/bahai_date/year.rb
|
44
103
|
- lib/bahai_date/year_calendar.rb
|
45
|
-
- lib/bahai_date/year_data.rb
|
46
104
|
- spec/bahai_date/bahai_date_spec.rb
|
47
105
|
- spec/bahai_date/day_spec.rb
|
106
|
+
- spec/bahai_date/logic_spec.rb
|
48
107
|
- spec/bahai_date/month_spec.rb
|
49
108
|
- spec/bahai_date/occasion_factory_spec.rb
|
50
109
|
- spec/bahai_date/occasion_spec.rb
|
51
110
|
- spec/bahai_date/weekday_spec.rb
|
52
111
|
- spec/bahai_date/year_calendar_spec.rb
|
53
|
-
- spec/bahai_date/year_data_spec.rb
|
54
112
|
- spec/bahai_date/year_spec.rb
|
55
113
|
- spec/spec_helper.rb
|
56
114
|
homepage: https://github.com/lessan/bahai-date
|
@@ -76,16 +134,15 @@ rubyforge_project:
|
|
76
134
|
rubygems_version: 2.2.2
|
77
135
|
signing_key:
|
78
136
|
specification_version: 4
|
79
|
-
summary:
|
80
|
-
(or Badi) calendar
|
137
|
+
summary: Conversion between Gregorian and Baha'i (or Badi) calendars
|
81
138
|
test_files:
|
82
139
|
- spec/spec_helper.rb
|
83
140
|
- spec/bahai_date/bahai_date_spec.rb
|
141
|
+
- spec/bahai_date/logic_spec.rb
|
84
142
|
- spec/bahai_date/occasion_factory_spec.rb
|
85
143
|
- spec/bahai_date/year_calendar_spec.rb
|
86
144
|
- spec/bahai_date/year_spec.rb
|
87
145
|
- spec/bahai_date/occasion_spec.rb
|
88
|
-
- spec/bahai_date/year_data_spec.rb
|
89
146
|
- spec/bahai_date/weekday_spec.rb
|
90
147
|
- spec/bahai_date/month_spec.rb
|
91
148
|
- spec/bahai_date/day_spec.rb
|
data/lib/bahai_date/year_data.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
module BahaiDate
|
2
|
-
class YearData
|
3
|
-
# valid up to 2148
|
4
|
-
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]
|
5
|
-
# valid up to 2149
|
6
|
-
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 }
|
7
|
-
|
8
|
-
def self.nawruz_for(year)
|
9
|
-
nawruz_day = year < 2015 ? 21 : NAWRUZ_DAYS[year]
|
10
|
-
Date.new(year, 3, nawruz_day)
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.leap?(year)
|
14
|
-
LEAP_YEARS.include? year
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module BahaiDate
|
2
|
-
describe YearData do
|
3
|
-
|
4
|
-
it 'supplies a Date object for Naw Ruz of a given year' do
|
5
|
-
expect(YearData.nawruz_for(1844)).to eq(Date.new(1844, 3, 21))
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'determines whether a year is leap or not' do
|
9
|
-
expect(YearData.leap?(1)).to eq(false)
|
10
|
-
expect(YearData.leap?(4)).to eq(true)
|
11
|
-
expect(YearData.leap?(168)).to eq(true)
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|