hebrew_date 1.0.10 → 1.0.11

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: d41b0baeb363a75a7b4e026cc80fadb18883a903
4
- data.tar.gz: c0cd4fe726dec3935c9369f008f66fd3f900e287
3
+ metadata.gz: 35508f471f98b8c7ef8bee61a474a8ef07b4f7b3
4
+ data.tar.gz: 7325bcdbed021dbfdd5e9b2433f95d3206fc118b
5
5
  SHA512:
6
- metadata.gz: eaec13486cd97491208b38df44c159cc932d80fcbacc25a2663b8fc33ff2fe2a5da13fd31ba4578b02ee49df8b1a83a263aab7b71b74fd5ed2377e6f094d1b99
7
- data.tar.gz: d04648a8a27f0c5ad2c0ca324249fb94d9f80b966a657286d13326dc3325c2b9afb2f71c2a8eca7252eb4ad046bbef167c2d2f4a6d371ec45f272075c138c5a8
6
+ metadata.gz: d9a26c8a810b30e48831a05870bfb7bac0b709bb6cb31daeb45fa824b2302371aa72f82195ce2ca33138fa60318ae97af11d5f54e3e4958d769907acc3b1ba35
7
+ data.tar.gz: 402fa96a1c29c90ef7c85f978a7111ae0e9ccc60c3b86964af4aa6a2d1f2660f3e398fc524784c1cebef797e3026ff61249dfcd020b71227ad1ab124e4eed68e
data/hebrew_date.gemspec CHANGED
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'hebrew_date'
3
3
  s.require_paths = %w(. lib)
4
- s.version = '1.0.10'
5
- s.date = '2014-01-31'
4
+ s.version = '1.0.11'
5
+ s.date = '2014-02-03'
6
6
  s.summary = 'Hebrew/Jewish dates, times, and holidays.'
7
7
  s.description = <<-EOF
8
8
  hebrew_date is a library designed to provide information about the Jewish
data/lib/hebrew_date.rb CHANGED
@@ -86,7 +86,7 @@ class HebrewDate < Delegator
86
86
  strftime('*Y-*-m-*-d (%Y-%-m-%-d)')
87
87
  end
88
88
 
89
- [:+, :-, :<<, :>>, :gregorian, :england, :italy, :julian, :new_start,
89
+ [:<<, :>>, :gregorian, :england, :italy, :julian, :new_start,
90
90
  :next_month, :next_year, :prev_day, :prev_month,
91
91
  :prev_year].each do |method_name|
92
92
  define_method(method_name) do |*args|
@@ -104,10 +104,24 @@ class HebrewDate < Delegator
104
104
  # do nothing
105
105
  end
106
106
 
107
- # Get a clone of this object.
107
+ # @param other [Fixnum]
108
108
  # @return [HebrewDate]
109
- def clone
110
- self.class.new(self.to_date)
109
+ def +(other)
110
+ date = self.clone
111
+ (1..other).each do |i|
112
+ date.forward
113
+ end
114
+ date
115
+ end
116
+
117
+ # @param other [Fixnum]
118
+ # @return [HebrewDate]
119
+ def -(other)
120
+ date = self.clone
121
+ (1..other).each do |i|
122
+ date.back
123
+ end
124
+ date
111
125
  end
112
126
 
113
127
  # Comparison operator.
@@ -312,7 +326,7 @@ class HebrewDate < Delegator
312
326
  # @param year [Integer]
313
327
  # @return [String]
314
328
  def self.hebrew_month_to_s(month, year=nil)
315
- year ||= HebrewDate.new.hebrew_year
329
+ year ||= self.class.new.hebrew_year
316
330
  if hebrew_leap_year?(year) && month == 12
317
331
  'Adar I'
318
332
  else
@@ -362,8 +376,8 @@ class HebrewDate < Delegator
362
376
  .gsub('*d', @hebrew_date.to_s.rjust(2, '0'))
363
377
  .gsub('*-d', @hebrew_date.to_s)
364
378
  .gsub('*e', @hebrew_date.to_s.rjust(2, ' '))
365
- if HebrewDate.replace_saturday && @hebrew_date.day == 7
366
- shab_name = HebrewDate.ashkenaz ? 'Shabbos' : 'Shabbat'
379
+ if self.class.replace_saturday && @hebrew_date.day == 7
380
+ shab_name = self.class.ashkenaz ? 'Shabbos' : 'Shabbat'
367
381
  format = format.gsub('%A', shab_name)
368
382
  .gsub('%^A', shab_name.upcase)
369
383
  .gsub('%a', shab_name[0..2])
@@ -502,10 +516,10 @@ class HebrewDate < Delegator
502
516
  if (conjunction_parts >= 19440) || # If new moon is at or after midday,
503
517
  (((conjunction_day.remainder(7)) == 2) && # ...or is on a Tuesday...
504
518
  (conjunction_parts >= 9924) && # at 9 hours, 204 parts or later...
505
- !HebrewDate.hebrew_leap_year?(year)) || # ...of a common year,
519
+ !self.class.hebrew_leap_year?(year)) || # ...of a common year,
506
520
  (((conjunction_day.remainder(7)) == 1) && # ...or is on a Monday at...
507
521
  (conjunction_parts >= 16789) && # 15 hours, 589 parts or later...
508
- (HebrewDate.hebrew_leap_year?(year - 1))) # at the end of a leap year
522
+ (self.class.hebrew_leap_year?(year - 1))) # at the end of a leap year
509
523
  # Then postpone Rosh HaShanah one day
510
524
  alternative_day += 1
511
525
  end
@@ -41,20 +41,20 @@ module HebrewDateSupport
41
41
  # @param year [Integer] if given, the Hebrew year to search. Defaults
42
42
  # to the current year.
43
43
  def from_holiday(holiday, year=nil)
44
- year ||= HebrewDate.new.hebrew_year
44
+ year ||= self.new.hebrew_year
45
45
  case holiday
46
46
  when :EREV_PESACH
47
- HebrewDate.new_from_hebrew(year, 1, 14)
47
+ self.new_from_hebrew(year, 1, 14)
48
48
  when :PESACH
49
- HebrewDate.new_from_hebrew(year, 1, 15)
49
+ self.new_from_hebrew(year, 1, 15)
50
50
  when :PESACH_2
51
- HebrewDate.new_from_hebrew(year, 1, 21)
51
+ self.new_from_hebrew(year, 1, 21)
52
52
  when :PESACH_SHENI
53
- HebrewDate.new_from_hebrew(year, 2, 15)
53
+ self.new_from_hebrew(year, 2, 15)
54
54
  when :YOM_HAZIKARON
55
- HebrewDate.from_holiday(:YOM_HAATZMAUT).back
55
+ self.from_holiday(:YOM_HAATZMAUT).back
56
56
  when :YOM_HAATZMAUT
57
- date = HebrewDate.new_from_hebrew(year, 2, 5)
57
+ date = self.new_from_hebrew(year, 2, 5)
58
58
  # Friday or Shabbat - move back to Thursday
59
59
  # Monday - move forward to Tuesday
60
60
  if date.day == 6
@@ -65,56 +65,56 @@ module HebrewDateSupport
65
65
  date.set_hebrew_date(year, 2, 3)
66
66
  end
67
67
  when :LAG_BAOMER
68
- HebrewDate.new_from_hebrew(year, 2, 18)
68
+ self.new_from_hebrew(year, 2, 18)
69
69
  when :YOM_YERUSHALAYIM
70
- HebrewDate.new_from_hebrew(year, 2, 28)
70
+ self.new_from_hebrew(year, 2, 28)
71
71
  when :TZOM_TAMMUZ
72
- date = HebrewDate.new_from_hebrew(year, 4, 17)
72
+ date = self.new_from_hebrew(year, 4, 17)
73
73
  date.forward if date.day == 7
74
74
  date
75
75
  when :EREV_SHAVUOT
76
- HebrewDate.new_from_hebrew(year, 3, 5)
76
+ self.new_from_hebrew(year, 3, 5)
77
77
  when :SHAVUOT
78
- HebrewDate.new_from_hebrew(year, 3, 6)
78
+ self.new_from_hebrew(year, 3, 6)
79
79
  when :TISHA_BAV
80
- date = HebrewDate.new_from_hebrew(year, 5, 9)
80
+ date = self.new_from_hebrew(year, 5, 9)
81
81
  date.forward if date.day == 7
82
82
  date
83
83
  when :TU_BAV
84
- HebrewDate.new_from_hebrew(year, 15, 9)
84
+ self.new_from_hebrew(year, 15, 9)
85
85
  when :EREV_ROSH_HASHANA
86
- HebrewDate.new_from_hebrew(year, 6, 29)
86
+ self.new_from_hebrew(year, 6, 29)
87
87
  when :ROSH_HASHANA
88
- HebrewDate.new_from_hebrew(year, 7, 1)
88
+ self.new_from_hebrew(year, 7, 1)
89
89
  when :TZOM_GEDALIA
90
- date = HebrewDate.new_from_hebrew(year, 7, 3)
90
+ date = self.new_from_hebrew(year, 7, 3)
91
91
  date.forward if date.day == 7
92
92
  date
93
93
  when :EREV_YOM_KIPPUR
94
- HebrewDate.new_from_hebrew(year, 7, 9)
94
+ self.new_from_hebrew(year, 7, 9)
95
95
  when :YOM_KIPPUR
96
- HebrewDate.new_from_hebrew(year, 7, 10)
96
+ self.new_from_hebrew(year, 7, 10)
97
97
  when :EREV_SUKKOT
98
- HebrewDate.new_from_hebrew(year, 7, 14)
98
+ self.new_from_hebrew(year, 7, 14)
99
99
  when :SUKKOT
100
- HebrewDate.new_from_hebrew(year, 7, 15)
100
+ self.new_from_hebrew(year, 7, 15)
101
101
  when :SHMINI_ATZERET
102
- HebrewDate.new_from_hebrew(year, 7, 22)
102
+ self.new_from_hebrew(year, 7, 22)
103
103
  when :EREV_CHANUKAH
104
- HebrewDate.new_from_hebrew(year, 9, 24)
104
+ self.new_from_hebrew(year, 9, 24)
105
105
  when :CHANUKAH
106
- HebrewDate.new_from_hebrew(year, 9, 25)
106
+ self.new_from_hebrew(year, 9, 25)
107
107
  when :TZOM_TEVET
108
- HebrewDate.new_from_hebrew(year, 10, 10)
108
+ self.new_from_hebrew(year, 10, 10)
109
109
  when :TU_BISHVAT
110
- HebrewDate.new_from_hebrew(year, 11, 15)
110
+ self.new_from_hebrew(year, 11, 15)
111
111
  when :PURIM_KATAN
112
- if HebrewDate.hebrew_leap_year?(year)
113
- HebrewDate.new_from_hebrew(year, 12, 14)
112
+ if self.hebrew_leap_year?(year)
113
+ self.new_from_hebrew(year, 12, 14)
114
114
  end
115
115
  when :TAANIT_ESTHER
116
- date = HebrewDate.new_from_hebrew(year,
117
- HebrewDate.last_month_of_hebrew_year(year), 13)
116
+ date = self.new_from_hebrew(year,
117
+ self.last_month_of_hebrew_year(year), 13)
118
118
  if date.day == 7
119
119
  date.set_hebrew_date(year, date.hebrew_month, 11)
120
120
  elsif date.day == 6
@@ -122,11 +122,11 @@ module HebrewDateSupport
122
122
  end
123
123
  date
124
124
  when :PURIM
125
- HebrewDate.new_from_hebrew(year,
126
- HebrewDate.last_month_of_hebrew_year(year), 14)
125
+ self.new_from_hebrew(year,
126
+ self.last_month_of_hebrew_year(year), 14)
127
127
  when :SHUSHAN_PURIM
128
- HebrewDate.new_from_hebrew(year,
129
- HebrewDate.last_month_of_hebrew_year(year), 15)
128
+ self.new_from_hebrew(year,
129
+ self.last_month_of_hebrew_year(year), 15)
130
130
  end
131
131
  end
132
132
  end
@@ -189,7 +189,7 @@ module HebrewDateSupport
189
189
  # index= the index number of the parsha name
190
190
  array = []
191
191
  # create a clone of this date
192
- rosh_hashana = HebrewDate.new_from_hebrew(@hebrew_year, 7, 1)
192
+ rosh_hashana = self.class.new_from_hebrew(@hebrew_year, 7, 1)
193
193
 
194
194
  # get day Rosh Hashana was on
195
195
  rosh_hashana_day = rosh_hashana.day
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hebrew_date
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Orner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-31 00:00:00.000000000 Z
11
+ date: 2014-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard