home_run 1.0.3-x86-mingw32 → 1.0.4-x86-mingw32
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/CHANGELOG +4 -0
- data/README.rdoc +2 -0
- data/ext/date_ext/datetime.c +14 -9
- data/lib/1.8/date_ext.so +0 -0
- data/lib/1.9/date_ext.so +0 -0
- data/spec/datetime/constructor_spec.rb +14 -0
- data/spec/datetime/conversions_spec.rb +4 -0
- metadata +4 -4
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -222,6 +222,8 @@ bugs, so please report any other differences you find.
|
|
222
222
|
Some other libraries are known to be incompatible with this
|
223
223
|
extension due to the above differences:
|
224
224
|
|
225
|
+
* ActiveSupport 3.1 - DateTime#<=> broken because it relies on
|
226
|
+
Date#<=> working for DateTimes.
|
225
227
|
* Date::Performance - Date#<=> assumes @ajd instance variable
|
226
228
|
(unnecessary anyway, as home_run is faster)
|
227
229
|
* Runt - assumes @ajd instance variable
|
data/ext/date_ext/datetime.c
CHANGED
@@ -512,6 +512,15 @@ VALUE rhrdt__new_offset(VALUE self, double offset) {
|
|
512
512
|
return rhrdt__from_jd_nanos(rb_obj_class(self), dt->jd, dt->nanos - (dt->offset - offset_min)*RHR_NANOS_PER_MINUTE, (short)offset_min);
|
513
513
|
}
|
514
514
|
|
515
|
+
/* Handle both string timezones and numeric offsets in
|
516
|
+
* constructors and new_offset */
|
517
|
+
double rhrdt__constructor_offset(VALUE self, VALUE offset) {
|
518
|
+
if (TYPE(offset) == T_STRING) {
|
519
|
+
return NUM2LONG(rhrd_s_zone_to_diff(self, offset))/RHR_SECONDS_PER_DAYD;
|
520
|
+
}
|
521
|
+
return NUM2DBL(offset);
|
522
|
+
}
|
523
|
+
|
515
524
|
/* Class methods */
|
516
525
|
|
517
526
|
/* call-seq:
|
@@ -618,7 +627,7 @@ static VALUE rhrdt_s_civil(int argc, VALUE *argv, VALUE klass) {
|
|
618
627
|
return rdt;
|
619
628
|
case 8:
|
620
629
|
case 7:
|
621
|
-
offset =
|
630
|
+
offset = rhrdt__constructor_offset(klass, argv[6]);
|
622
631
|
case 6:
|
623
632
|
second = NUM2LONG(argv[5]);
|
624
633
|
case 5:
|
@@ -672,7 +681,7 @@ static VALUE rhrdt_s_commercial(int argc, VALUE *argv, VALUE klass) {
|
|
672
681
|
switch(argc) {
|
673
682
|
case 8:
|
674
683
|
case 7:
|
675
|
-
offset =
|
684
|
+
offset = rhrdt__constructor_offset(klass, argv[6]);
|
676
685
|
case 6:
|
677
686
|
second = NUM2LONG(argv[5]);
|
678
687
|
case 5:
|
@@ -727,7 +736,7 @@ static VALUE rhrdt_s_jd(int argc, VALUE *argv, VALUE klass) {
|
|
727
736
|
return rdt;
|
728
737
|
case 6:
|
729
738
|
case 5:
|
730
|
-
offset =
|
739
|
+
offset = rhrdt__constructor_offset(klass, argv[4]);
|
731
740
|
case 4:
|
732
741
|
second = NUM2LONG(argv[3]);
|
733
742
|
case 3:
|
@@ -842,7 +851,7 @@ static VALUE rhrdt_s_ordinal(int argc, VALUE *argv, VALUE klass) {
|
|
842
851
|
switch(argc) {
|
843
852
|
case 7:
|
844
853
|
case 6:
|
845
|
-
offset =
|
854
|
+
offset = rhrdt__constructor_offset(klass, argv[5]);
|
846
855
|
case 5:
|
847
856
|
second = NUM2LONG(argv[4]);
|
848
857
|
case 4:
|
@@ -1378,11 +1387,7 @@ static VALUE rhrdt_new_offset(int argc, VALUE *argv, VALUE self) {
|
|
1378
1387
|
offset = 0;
|
1379
1388
|
break;
|
1380
1389
|
case 1:
|
1381
|
-
|
1382
|
-
offset = NUM2LONG(rhrd_s_zone_to_diff(self, argv[0]))/RHR_SECONDS_PER_DAYD;
|
1383
|
-
} else {
|
1384
|
-
offset = NUM2DBL(argv[0]);
|
1385
|
-
}
|
1390
|
+
offset= rhrdt__constructor_offset(rb_obj_class(self), argv[0]);
|
1386
1391
|
break;
|
1387
1392
|
default:
|
1388
1393
|
rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
|
data/lib/1.8/date_ext.so
CHANGED
Binary file
|
data/lib/1.9/date_ext.so
CHANGED
Binary file
|
@@ -149,4 +149,18 @@ describe "DateTime constructors" do
|
|
149
149
|
c.new!.should be_kind_of(c)
|
150
150
|
c.new.should be_kind_of(c)
|
151
151
|
end
|
152
|
+
|
153
|
+
it "should handle strings for the offset" do
|
154
|
+
DateTime.jd(2008, 0, 0, 0, 'Z').should == DateTime.jd(2008, 0, 0, 0, 0)
|
155
|
+
DateTime.civil(2008, 1, 1, 0, 0, 0, 'Z').should == DateTime.civil(2008, 1, 1, 0, 0, 0, 0)
|
156
|
+
DateTime.commercial(2008, 1, 1, 0, 0, 0, 'Z').should == DateTime.commercial(2008, 1, 1, 0, 0, 0, 0)
|
157
|
+
DateTime.ordinal(2008, 1, 0, 0, 0, 'Z').should == DateTime.ordinal(2008, 1, 0, 0, 0, 0)
|
158
|
+
DateTime.new(2008, 1, 1, 0, 0, 0, 'Z').should == DateTime.new(2008, 1, 1, 0, 0, 0, 0)
|
159
|
+
|
160
|
+
DateTime.jd(2008, 0, 0, 0, '+1200').should == DateTime.jd(2008, 0, 0, 0, 0.5)
|
161
|
+
DateTime.civil(2008, 1, 1, 0, 0, 0, '+1200').should == DateTime.civil(2008, 1, 1, 0, 0, 0, 0.5)
|
162
|
+
DateTime.commercial(2008, 1, 1, 0, 0, 0, '+1200').should == DateTime.commercial(2008, 1, 1, 0, 0, 0, 0.5)
|
163
|
+
DateTime.ordinal(2008, 1, 0, 0, 0, '+1200').should == DateTime.ordinal(2008, 1, 0, 0, 0, 0.5)
|
164
|
+
DateTime.new(2008, 1, 1, 0, 0, 0, '+1200').should == DateTime.new(2008, 1, 1, 0, 0, 0, 0.5)
|
165
|
+
end
|
152
166
|
end
|
@@ -5,6 +5,10 @@ describe "DateTime conversions" do
|
|
5
5
|
DateTime.new(2008, 1, 1).new_offset(0.5).to_s.should == DateTime.new(2008, 1, 1, 12, 0, 0, 0.5).to_s
|
6
6
|
end
|
7
7
|
|
8
|
+
it "#new_offset should work with strings" do
|
9
|
+
DateTime.new(2008, 1, 1).new_offset('+12:00').to_s.should == DateTime.new(2008, 1, 1, 12, 0, 0, 0.5).to_s
|
10
|
+
end
|
11
|
+
|
8
12
|
it "#new_offset result should be equal to the receiver" do
|
9
13
|
DateTime.new(2008, 1, 1).new_offset(0.5).should == DateTime.new(2008, 1, 1)
|
10
14
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: home_run
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 4
|
10
|
+
version: 1.0.4
|
11
11
|
platform: x86-mingw32
|
12
12
|
authors:
|
13
13
|
- Jeremy Evans
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-09-02 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|