hebrew_date 1.0.12 → 1.0.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24d30d98a5b4e655ed1d8394c69721ac66bceee7
4
- data.tar.gz: a07b4a0f4d44c9f1c71656659cb8dcb85cfd28be
3
+ metadata.gz: dd6b7e10cb6a8302d5684530f17d395aa62195c4
4
+ data.tar.gz: 927c92e5d3f20df9ab055a52780a7f5d038c1c29
5
5
  SHA512:
6
- metadata.gz: e0e483760e3c7098bd702c5a8f3438805c958ca0c5ac828a1f03ea72bbdd060158d7dfe26deb74154100e73fc40f0ceb75c06fa610352ac8dff71a4a65158c79
7
- data.tar.gz: 3ea8a572c90e14c61e8a8bbfdfb034a2dd91ba5d5daee2fedc39bb03c4e5056bf00246bf7cdf5e824d3aaf27d30ae5dc03fd55cc32af0c2fe40d93f0636c3450
6
+ metadata.gz: 67b477cbe1da00c1a13ae4369d5a6b8ebe3ccce307e7e91b6b1a157050f0226a448771d26d6600c9526e5736addb4b4539bd6f12c0f56fc0f28c7d3d1e46d936
7
+ data.tar.gz: dd3a9e11529357ef0fea68e59b702c48cb57c8ce81ad6703be6628156f9acb99e07076d48e2ea28e1a92ee4db0f87889411ec6133240a37c949670a3417686ce
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.12'
5
- s.date = '2014-02-03'
4
+ s.version = '1.0.13'
5
+ s.date = '2014-02-15'
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
@@ -63,6 +63,11 @@ class HebrewDate < Delegator
63
63
 
64
64
  def initialize(year_or_date_object=nil, month=nil, date=nil)
65
65
  @abs_date = 0
66
+ skip_hebrew_date = false
67
+ if year_or_date_object === true
68
+ skip_hebrew_date = true
69
+ year_or_date_object = nil
70
+ end
66
71
 
67
72
  if month && date
68
73
  @year = year_or_date_object
@@ -77,7 +82,7 @@ class HebrewDate < Delegator
77
82
  @israeli = self.class.israeli
78
83
  @ashkenaz = self.class.ashkenaz
79
84
  @debug = self.class.debug
80
- set_date(@year, @month, @date)
85
+ set_date(@year, @month, @date) unless skip_hebrew_date
81
86
  super(Date.new)
82
87
  end
83
88
 
@@ -159,8 +164,11 @@ class HebrewDate < Delegator
159
164
  # @param month [Integer] the Hebrew month (1-13)
160
165
  # @param date [Integer] the day of the Hebrew month (1-30)
161
166
  def self.new_from_hebrew(year, month, date)
162
- d = self.new
163
- d.set_hebrew_date(year, month, date)
167
+ d = self.new(true)
168
+ @year = 1
169
+ @month = 1
170
+ @date = 1
171
+ d.set_hebrew_date(year, month, date, true)
164
172
  d
165
173
  end
166
174
 
@@ -193,8 +201,14 @@ class HebrewDate < Delegator
193
201
  # @param year [Integer] the Hebrew year (e.g. 2008)
194
202
  # @param month [Integer] the Hebrew month (1-13)
195
203
  # @param date [Integer] the Hebrew day of month (1-30)
204
+ # @param auto_set [Boolean] Used internally.
196
205
  # @return [void]
197
- def set_hebrew_date(year, month, date)
206
+ def set_hebrew_date(year, month, date, auto_set=false)
207
+ if auto_set
208
+ @hebrew_year = year
209
+ @hebrew_month = month
210
+ @hebrew_date = date
211
+ end
198
212
  return "Illegal value for Hebrew year: #{year}" if year < 0
199
213
  if month < 0 || month > last_month_of_hebrew_year
200
214
  return "Illegal value for Hebrew month: #{month}"
@@ -500,7 +514,7 @@ class HebrewDate < Delegator
500
514
  # @param year [Integer]
501
515
  # @return [Integer]
502
516
  def _hebrew_calendar_elapsed_days(year)
503
- puts "hebrew_calendar_elapsed_days #{year}" if @debug
517
+ # puts "hebrew_calendar_elapsed_days #{year}" if @debug
504
518
  months_elapsed =
505
519
  (235 * ((year - 1) / 19.0).to_i) + # Months in complete cycles so far
506
520
  (12 * ((year - 1).remainder(19))) + # Regular months in this cycle
@@ -529,7 +543,7 @@ class HebrewDate < Delegator
529
543
  if [0, 3, 5].include?(alternative_day.remainder(7))
530
544
  alternative_day += 1
531
545
  end
532
- puts "hebrew_calendar_elapsed_days calculated #{alternative_day}" if @debug
546
+ # puts "hebrew_calendar_elapsed_days calculated #{alternative_day}" if @debug
533
547
  alternative_day
534
548
  end
535
549
 
@@ -552,8 +566,14 @@ class HebrewDate < Delegator
552
566
  # @return [void]
553
567
  def _abs_date_to_hebrew_date!
554
568
  puts "abs_date_to_hebrew_date #{@abs_date}" if @debug
555
- # Approximation from below.
556
- @hebrew_year = ((@abs_date + HEBREW_EPOCH) / 366.0).ceil
569
+ # Speed this up - most dates will be current, so let's use a value
570
+ # we know about.
571
+ if @abs_date >= 735279
572
+ @hebrew_year = 5770
573
+ else
574
+ # Approximation from below.
575
+ @hebrew_year = ((@abs_date + HEBREW_EPOCH) / 366.0).ceil
576
+ end
557
577
  # Search forward for year from the approximation.
558
578
  while @abs_date >= _hebrew_date_to_abs_date(@hebrew_year + 1, 7, 1) do
559
579
  @hebrew_year += 1
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.12
4
+ version: 1.0.13
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-02-03 00:00:00.000000000 Z
11
+ date: 2014-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard