tzinfo 0.3.27 → 0.3.28

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of tzinfo might be problematic. Click here for more details.

data/CHANGES CHANGED
@@ -1,3 +1,10 @@
1
+ == Version 0.3.28 (tzdata v2011g) - 13-Jun-2011
2
+
3
+ * Add support for Ruby 1.9.3 (trunk revision 31668 and later). Thanks to
4
+ Aaron Patterson for reporting the problems running on the new version.
5
+ Closes #29233.
6
+
7
+
1
8
  == Version 0.3.27 (tzdata v2011g) - 26-Apr-2011
2
9
 
3
10
  * Updated to tzdata version 2011g
data/Rakefile CHANGED
@@ -40,7 +40,7 @@ def sh(*cmd, &block)
40
40
  end
41
41
 
42
42
 
43
- PKG_VERSION = "0.3.27"
43
+ PKG_VERSION = "0.3.28"
44
44
  PKG_FILES = FileList[
45
45
  'CHANGES',
46
46
  'LICENSE',
@@ -42,15 +42,39 @@ module TZInfo
42
42
 
43
43
  # Ruby 1.8.6 introduced new! and deprecated new0.
44
44
  # Ruby 1.9.0 removed new0.
45
- # We still need to support new0 for older versions of Ruby.
45
+ # Ruby trunk revision 31668 removed the new! method.
46
+ # Still support new0 for better performance on older versions of Ruby (new0 indicates
47
+ # that the rational has already been reduced to its lowest terms).
48
+ # Fallback to jd with conversion from ajd if new! and new0 are unavailable.
46
49
  if DateTime.respond_to? :new!
47
50
  def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY)
48
51
  DateTime.new!(ajd, of, sg)
49
52
  end
50
- else
53
+ elsif DateTime.respond_to? :new0
51
54
  def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY)
52
55
  DateTime.new0(ajd, of, sg)
53
56
  end
57
+ else
58
+ HALF_DAYS_IN_DAY = rational_new!(1, 2)
59
+
60
+ def self.datetime_new!(ajd = 0, of = 0, sg = Date::ITALY)
61
+ # Convert from an Astronomical Julian Day number to a civil Julian Day number.
62
+ jd = ajd + of + HALF_DAYS_IN_DAY
63
+
64
+ # Ruby trunk revision 31862 changed the behaviour of DateTime.jd so that it will no
65
+ # longer accept a fractional civil Julian Day number if further arguments are specified.
66
+ # Calculate the hours, minutes and seconds to pass to jd.
67
+
68
+ jd_i = jd.to_i
69
+ jd_i -= 1 if jd < 0
70
+ hours = (jd - jd_i) * 24
71
+ hours_i = hours.to_i
72
+ minutes = (hours - hours_i) * 60
73
+ minutes_i = minutes.to_i
74
+ seconds = (minutes - minutes_i) * 60
75
+
76
+ DateTime.jd(jd_i, hours_i, minutes_i, seconds, of, sg)
77
+ end
54
78
  end
55
79
  end
56
80
  end
@@ -10,6 +10,22 @@ class TCRubyCoreSupport < Test::Unit::TestCase
10
10
  end
11
11
 
12
12
  def test_datetime_new!
13
- assert_equal(DateTime.new(2008,10,6,20,30,0, 1, Date::ITALY), RubyCoreSupport.datetime_new!(Rational(117827777, 48),1,2299161))
13
+ assert_equal(DateTime.new(2008,10,5,12,0,0, 0, Date::ITALY), RubyCoreSupport.datetime_new!(2454745,0,2299161))
14
+ assert_equal(DateTime.new(2008,10,6,12,0,0, 1, Date::ITALY), RubyCoreSupport.datetime_new!(2454745,1,2299161))
15
+
16
+ assert_equal(DateTime.new(2008,10,5,20,30,0, 0, Date::ITALY), RubyCoreSupport.datetime_new!(Rational(117827777, 48), 0, 2299161))
17
+ assert_equal(DateTime.new(2008,10,6,20,30,0, 1, Date::ITALY), RubyCoreSupport.datetime_new!(Rational(117827777, 48), 1, 2299161))
18
+
19
+ assert_equal(DateTime.new(2008,10,6,6,26,21, 0, Date::ITALY), RubyCoreSupport.datetime_new!(Rational(70696678127,28800), 0, 2299161))
20
+ assert_equal(DateTime.new(2008,10,7,6,26,21, 1, Date::ITALY), RubyCoreSupport.datetime_new!(Rational(70696678127, 28800), 1, 2299161))
21
+
22
+ assert_equal(DateTime.new(-4712,1,1,12,0,0, 0, Date::ITALY), RubyCoreSupport.datetime_new!(0, 0, 2299161))
23
+ assert_equal(DateTime.new(-4712,1,2,12,0,0, 1, Date::ITALY), RubyCoreSupport.datetime_new!(0, 1, 2299161))
24
+
25
+ assert_equal(DateTime.new(-4713,12,31,10,58,59, 0, Date::ITALY), RubyCoreSupport.datetime_new!(Rational(-90061, 86400), 0, 2299161))
26
+ assert_equal(DateTime.new(-4712,1,1,10,58,59, 1, Date::ITALY), RubyCoreSupport.datetime_new!(Rational(-90061, 86400), 1, 2299161))
27
+
28
+ assert_equal(DateTime.new(-4713,12,30,10,58,59, 0, Date::ITALY), RubyCoreSupport.datetime_new!(Rational(-176461, 86400), 0, 2299161))
29
+ assert_equal(DateTime.new(-4713,12,31,10,58,59, 1, Date::ITALY), RubyCoreSupport.datetime_new!(Rational(-176461, 86400), 1, 2299161))
14
30
  end
15
31
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tzinfo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 37
4
+ hash: 43
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 27
10
- version: 0.3.27
9
+ - 28
10
+ version: 0.3.28
11
11
  platform: ruby
12
12
  authors:
13
13
  - Philip Ross
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-25 16:00:00 -07:00
18
+ date: 2011-06-12 16:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21