tzinfo 0.3.27 → 0.3.28
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.
- data/CHANGES +7 -0
- data/Rakefile +1 -1
- data/lib/tzinfo/ruby_core_support.rb +26 -2
- data/test/tc_ruby_core_support.rb +17 -1
- metadata +4 -4
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
|
@@ -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
|
-
#
|
|
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
|
-
|
|
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,
|
|
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:
|
|
4
|
+
hash: 43
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 3
|
|
9
|
-
-
|
|
10
|
-
version: 0.3.
|
|
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-
|
|
18
|
+
date: 2011-06-12 16:00:00 -07:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies: []
|
|
21
21
|
|