home_run 1.0.4-x86-mswin32-60 → 1.0.5-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.0.5 (2012-12-22)
2
+
3
+ * Handle DateTime.jd with a single float argument (jeremyevans)
4
+
1
5
  === 1.0.4 (2011-09-02)
2
6
 
3
7
  * Handle time zone offsets given as strings in the constructors (jeremyevans) (#37)
@@ -743,6 +743,9 @@ static VALUE rhrdt_s_jd(int argc, VALUE *argv, VALUE klass) {
743
743
  minute = NUM2LONG(argv[2]);
744
744
  case 2:
745
745
  hour = NUM2LONG(argv[1]);
746
+ if (TYPE(argv[0]) == T_FLOAT) {
747
+ rb_raise(rb_eArgError, "can't use float for first argument if providing multiple arguments");
748
+ }
746
749
  case 1:
747
750
  dt->jd = NUM2LONG(argv[0]);
748
751
  break;
@@ -754,7 +757,11 @@ static VALUE rhrdt_s_jd(int argc, VALUE *argv, VALUE klass) {
754
757
  RHR_CHECK_JD(dt)
755
758
  dt->flags = RHR_HAVE_JD;
756
759
  rhrdt__set_time(dt, hour, minute, second, offset);
757
- return rdt;
760
+ if (TYPE(argv[0]) == T_FLOAT) {
761
+ return rhrdt__add_days(rdt, NUM2DBL(argv[0]) - NUM2LONG(argv[0]));
762
+ } else {
763
+ return rdt;
764
+ }
758
765
  }
759
766
 
760
767
  /* call-seq:
Binary file
Binary file
@@ -72,6 +72,19 @@ describe "DateTime constructors" do
72
72
  d.offset.should == 1/24.0
73
73
  end
74
74
 
75
+ it ".jd handles a fractional date as first argument" do
76
+ d = DateTime.jd(2000.5)
77
+ d.jd.should == 2000
78
+ d.hour.should == 12
79
+ d.min.should == 0
80
+ d.sec.should == 0
81
+ d.offset.should == 0
82
+ end
83
+
84
+ it ".jd should raise an error if given a float as first argument and any additional arguments" do
85
+ proc{DateTime.jd(2000.5, 1)}.should raise_error(ArgumentError)
86
+ end
87
+
75
88
  it ".jd should have defaults and an optional sg value" do
76
89
  DateTime.jd.should == DateTime.jd(0, 0, 0, 0, 0)
77
90
  DateTime.jd(0).should == DateTime.jd(0, 0, 0, 0, 0)
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: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 4
10
- version: 1.0.4
9
+ - 5
10
+ version: 1.0.5
11
11
  platform: x86-mswin32-60
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-09-02 00:00:00 -07:00
18
+ date: 2011-11-01 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21