home_run 0.9.3-x86-mswin32-60 → 0.9.4-x86-mswin32-60

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.
Files changed (40) hide show
  1. data/CHANGELOG +4 -0
  2. data/README.rdoc +0 -1
  3. data/ext/date_ext/date_ext.c +192 -191
  4. data/ext/date_ext/datetime.c +12 -11
  5. data/lib/1.8/date_ext.so +0 -0
  6. data/lib/1.9/date_ext.so +0 -0
  7. data/spec/date/add_month_spec.rb +5 -0
  8. data/spec/date/add_spec.rb +5 -0
  9. data/spec/date/civil_spec.rb +5 -1
  10. data/spec/date/commercial_spec.rb +5 -0
  11. data/spec/date/conversions_spec.rb +10 -0
  12. data/spec/date/downto_spec.rb +6 -0
  13. data/spec/date/julian_spec.rb +10 -0
  14. data/spec/date/minus_month_spec.rb +5 -0
  15. data/spec/date/minus_spec.rb +5 -0
  16. data/spec/date/next_prev_spec.rb +30 -1
  17. data/spec/date/ordinal_spec.rb +5 -0
  18. data/spec/date/parse_spec.rb +6 -0
  19. data/spec/date/parsing_spec.rb +11 -0
  20. data/spec/date/step_spec.rb +6 -0
  21. data/spec/date/strptime_spec.rb +6 -0
  22. data/spec/date/succ_spec.rb +5 -0
  23. data/spec/date/today_spec.rb +5 -0
  24. data/spec/date/upto_spec.rb +7 -0
  25. data/spec/datetime/add_month_spec.rb +5 -0
  26. data/spec/datetime/add_spec.rb +5 -0
  27. data/spec/datetime/constructor_spec.rb +10 -0
  28. data/spec/datetime/conversions_spec.rb +5 -0
  29. data/spec/datetime/downto_spec.rb +6 -0
  30. data/spec/datetime/minus_month_spec.rb +5 -2
  31. data/spec/datetime/minus_spec.rb +5 -0
  32. data/spec/datetime/next_prev_spec.rb +30 -0
  33. data/spec/datetime/now_spec.rb +5 -0
  34. data/spec/datetime/parse_spec.rb +6 -0
  35. data/spec/datetime/parsing_spec.rb +11 -0
  36. data/spec/datetime/step_spec.rb +6 -0
  37. data/spec/datetime/strptime_spec.rb +6 -0
  38. data/spec/datetime/succ_spec.rb +5 -0
  39. data/spec/datetime/upto_spec.rb +6 -0
  40. metadata +4 -4
@@ -307,11 +307,11 @@ void rhrdt__now(rhrdt_t * dt) {
307
307
  * the number per day by subtracting from or adding to the jd.
308
308
  * It should ensure that the stored nanos value is in the range
309
309
  * [0, RHR_NANOS_PER_DAY). */
310
- VALUE rhrdt__from_jd_nanos(long jd, long long nanos, short offset) {
310
+ VALUE rhrdt__from_jd_nanos(VALUE klass, long jd, long long nanos, short offset) {
311
311
  long t;
312
312
  rhrdt_t *dt;
313
313
  VALUE new;
314
- new = Data_Make_Struct(rhrdt_class, rhrdt_t, NULL, -1, dt);
314
+ new = Data_Make_Struct(klass, rhrdt_t, NULL, -1, dt);
315
315
 
316
316
  if (nanos < 0) {
317
317
  t = (long)(nanos/RHR_NANOS_PER_DAY - 1);
@@ -363,7 +363,7 @@ VALUE rhrdt__add_days(VALUE self, double n) {
363
363
  RHRDT_FILL_NANOS(dt)
364
364
  l = (long)floor(n);
365
365
  nanos = llround((n - l) * RHR_NANOS_PER_DAY);
366
- return rhrdt__from_jd_nanos(rhrd__safe_add_long(dt->jd, l), dt->nanos + nanos, dt->offset);
366
+ return rhrdt__from_jd_nanos(rb_obj_class(self), rhrd__safe_add_long(dt->jd, l), dt->nanos + nanos, dt->offset);
367
367
  }
368
368
 
369
369
  /* Similar to rhrd__add_months, but for ruby DateTime
@@ -375,7 +375,7 @@ VALUE rhrdt__add_months(VALUE self, long n) {
375
375
  long x;
376
376
  Data_Get_Struct(self, rhrdt_t, d);
377
377
 
378
- new = Data_Make_Struct(rhrdt_class, rhrdt_t, NULL, -1, newd);
378
+ new = Data_Make_Struct(rb_obj_class(self), rhrdt_t, NULL, -1, newd);
379
379
  RHRDT_FILL_CIVIL(d)
380
380
  memcpy(newd, d, sizeof(rhrdt_t));
381
381
 
@@ -509,7 +509,7 @@ VALUE rhrdt__new_offset(VALUE self, double offset) {
509
509
  Data_Get_Struct(self, rhrdt_t, dt);
510
510
  RHRDT_FILL_JD(dt)
511
511
  RHRDT_FILL_NANOS(dt)
512
- return rhrdt__from_jd_nanos(dt->jd, dt->nanos - (dt->offset - offset_min)*RHR_NANOS_PER_MINUTE, (short)offset_min);
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
515
  /* Class methods */
@@ -1453,7 +1453,7 @@ static VALUE rhrdt_step(int argc, VALUE *argv, VALUE self) {
1453
1453
  double step, limit;
1454
1454
  long long step_nanos, limit_nanos, current_nanos;
1455
1455
  long step_jd, limit_jd, current_jd;
1456
- VALUE rlimit, new, rstep, new_off;
1456
+ VALUE rlimit, new, rstep, new_off, klass;
1457
1457
  new_off = rhrdt__new_offset(self, 0.0);
1458
1458
  Data_Get_Struct(self, rhrdt_t, d);
1459
1459
  Data_Get_Struct(new_off, rhrdt_t, d0);
@@ -1475,6 +1475,7 @@ static VALUE rhrdt_step(int argc, VALUE *argv, VALUE self) {
1475
1475
  break;
1476
1476
  }
1477
1477
  rlimit = argv[0];
1478
+ klass = rb_obj_class(self);
1478
1479
 
1479
1480
  #ifdef RUBY19
1480
1481
  if (!rb_block_given_p()) {
@@ -1510,12 +1511,12 @@ static VALUE rhrdt_step(int argc, VALUE *argv, VALUE self) {
1510
1511
 
1511
1512
  current_jd = d0->jd;
1512
1513
  current_nanos = d0->nanos;
1513
- new = rhrdt__from_jd_nanos(current_jd, current_nanos, d->offset);
1514
+ new = rhrdt__from_jd_nanos(klass, current_jd, current_nanos, d->offset);
1514
1515
  if (limit_jd > current_jd || (limit_jd == current_jd && limit_nanos > current_nanos)) {
1515
1516
  if (step_jd > 0 || (step_jd == 0 && step_nanos > 0)) {
1516
1517
  while (limit_jd > current_jd || (limit_jd == current_jd && limit_nanos >= current_nanos)) {
1517
1518
  rb_yield(new);
1518
- new = rhrdt__from_jd_nanos(current_jd + step_jd, current_nanos + step_nanos, d->offset);
1519
+ new = rhrdt__from_jd_nanos(klass, current_jd + step_jd, current_nanos + step_nanos, d->offset);
1519
1520
  Data_Get_Struct(new, rhrdt_t, ndt);
1520
1521
  current_jd = ndt->jd;
1521
1522
  current_nanos = ndt->nanos;
@@ -1525,7 +1526,7 @@ static VALUE rhrdt_step(int argc, VALUE *argv, VALUE self) {
1525
1526
  if (step_jd < 0 || (step_jd == 0 && step_nanos < 0)) {
1526
1527
  while (limit_jd < current_jd || (limit_jd == current_jd && limit_nanos <= current_nanos)) {
1527
1528
  rb_yield(new);
1528
- new = rhrdt__from_jd_nanos(current_jd + step_jd, current_nanos + step_nanos, d->offset);
1529
+ new = rhrdt__from_jd_nanos(klass, current_jd + step_jd, current_nanos + step_nanos, d->offset);
1529
1530
  Data_Get_Struct(new, rhrdt_t, ndt);
1530
1531
  current_jd = ndt->jd;
1531
1532
  current_nanos = ndt->nanos;
@@ -1924,7 +1925,7 @@ VALUE rhrdt__add_years(VALUE self, long n) {
1924
1925
  VALUE new;
1925
1926
  Data_Get_Struct(self, rhrdt_t, d);
1926
1927
 
1927
- new = Data_Make_Struct(rhrdt_class, rhrdt_t, NULL, -1, newd);
1928
+ new = Data_Make_Struct(rb_obj_class(self), rhrdt_t, NULL, -1, newd);
1928
1929
  RHRDT_FILL_CIVIL(d)
1929
1930
  memcpy(newd, d, sizeof(rhrdt_t));
1930
1931
 
@@ -2605,7 +2606,7 @@ static VALUE rhrdt_to_time(VALUE self) {
2605
2606
  Data_Get_Struct(self, rhrdt_t, dt);
2606
2607
  RHRDT_FILL_JD(dt)
2607
2608
  RHRDT_FILL_NANOS(dt)
2608
- self = rhrdt__from_jd_nanos(dt->jd, dt->nanos - dt->offset * RHR_NANOS_PER_MINUTE, 0);
2609
+ self = rhrdt__from_jd_nanos(rb_obj_class(self), dt->jd, dt->nanos - dt->offset * RHR_NANOS_PER_MINUTE, 0);
2609
2610
  Data_Get_Struct(self, rhrdt_t, dt);
2610
2611
  RHRDT_FILL_CIVIL(dt)
2611
2612
  RHRDT_FILL_HMS(dt)
Binary file
Binary file
@@ -17,6 +17,11 @@ describe "Date#>>" do
17
17
  d.should == Date.civil(2008, 4, 30)
18
18
  end
19
19
 
20
+ it "should keep the same class as the receiver" do
21
+ c = Class.new(Date)
22
+ c.jd.>>(-10).should be_kind_of(c)
23
+ end
24
+
20
25
  it "should raise an error on non numeric parameters" do
21
26
  lambda { Date.civil(2007,2,27) >> "hello" }.should raise_error(TypeError)
22
27
  lambda { Date.civil(2007,2,27) >> Date.new }.should raise_error(TypeError)
@@ -14,6 +14,11 @@ describe "Date#+" do
14
14
  d.should == Date.civil(2007, 2, 17)
15
15
  end
16
16
 
17
+ it "should keep the same class as the receiver" do
18
+ c = Class.new(Date)
19
+ c.jd.+(10).should be_kind_of(c)
20
+ end
21
+
17
22
  it "should raise an error on non numeric parameters" do
18
23
  lambda { Date.civil(2007,2,27) + "hello" }.should raise_error(TypeError)
19
24
  lambda { Date.civil(2007,2,27) + Date.new }.should raise_error(TypeError)
@@ -67,6 +67,11 @@ describe "Date.civil" do
67
67
  proc{Date.civil(2008, 2, 30)}.should raise_error(ArgumentError)
68
68
  proc{Date.civil(2009, 2, 29)}.should raise_error(ArgumentError)
69
69
  end
70
+
71
+ it "should keep the same class as the receiver" do
72
+ c = Class.new(Date)
73
+ c.civil.should be_kind_of(c)
74
+ end
70
75
  end
71
76
 
72
77
  describe "Date.new" do
@@ -143,5 +148,4 @@ describe "Date.valid_civil?" do
143
148
  Date.valid_civil?(2008, -11, -10).should == true
144
149
  end
145
150
  end
146
-
147
151
  end
@@ -91,6 +91,11 @@ describe "Date.commercial" do
91
91
  proc{Date.commercial(2008, 54, 6)}.should raise_error(ArgumentError)
92
92
  proc{Date.commercial(2009, 1, 8)}.should raise_error(ArgumentError)
93
93
  end
94
+
95
+ it "should keep the same class as the receiver" do
96
+ c = Class.new(Date)
97
+ c.commercial.should be_kind_of(c)
98
+ end
94
99
  end
95
100
 
96
101
  ruby_version_is "" ... "1.9" do
@@ -9,6 +9,11 @@ describe "Date#new_start" do
9
9
  Date.civil(1752, 9, 13).new_start(Date::ENGLAND).should == Date.civil(1752, 9, 13, Date::ENGLAND)
10
10
  end
11
11
 
12
+ it "should keep the same class as the receiver" do
13
+ c = Class.new(Date)
14
+ c.jd.new_start.should be_kind_of(c)
15
+ end
16
+
12
17
  ruby_version_is "" ... "1.9" do
13
18
  it "#newsg should be the same as new_start" do
14
19
  Date.civil(1582, 10, 14, Date::ENGLAND).newsg.should == Date.civil(1582, 10, 14, Date::ENGLAND).new_start
@@ -45,6 +50,11 @@ describe "Date#gregorian" do
45
50
  Date.civil(1582, 10, 14).gregorian.should == Date.civil(1582, 10, 14, Date::GREGORIAN)
46
51
  Date.civil(1752, 9, 14).gregorian.should == Date.civil(1752, 9, 14, Date::GREGORIAN)
47
52
  end
53
+
54
+ it "should keep the same class as the receiver" do
55
+ c = Class.new(Date)
56
+ c.jd.gregorian.should be_kind_of(c)
57
+ end
48
58
  end
49
59
 
50
60
  ruby_version_is "" ... "1.9" do
@@ -14,4 +14,10 @@ describe "Date#downto" do
14
14
  count.should == 17
15
15
  end
16
16
 
17
+ it "should keep the same class as the receiver" do
18
+ c = Class.new(Date)
19
+ c.jd.downto(c.jd - 2) do |d|
20
+ d.should be_kind_of(c)
21
+ end.should be_kind_of(c)
22
+ end
17
23
  end
@@ -24,6 +24,11 @@ describe "Date.jd" do
24
24
  proc{Date.jd(Date::JULIAN)}.should raise_error
25
25
  end
26
26
 
27
+ it "should keep the same class as the receiver" do
28
+ c = Class.new(Date)
29
+ c.jd.should be_kind_of(c)
30
+ end
31
+
27
32
  ruby_version_is "" ... "1.9" do
28
33
  it ".new1 should be the same as jd" do
29
34
  Date.new1(2454156).should == Date.jd(2454156)
@@ -43,6 +48,11 @@ describe "Date.new!" do
43
48
  Date.new!(2008, 1, 1).should == Date.jd(2008)
44
49
  end
45
50
 
51
+ it "should keep the same class as the receiver" do
52
+ c = Class.new(Date)
53
+ c.new!.should be_kind_of(c)
54
+ end
55
+
46
56
  it "should not accept more than 3 arguments" do
47
57
  proc{Date.new!(2008, 1, 1, 1)}.should raise_error(ArgumentError)
48
58
  end
@@ -16,6 +16,11 @@ describe "Date#<<" do
16
16
  d.should == Date.civil(2008, 2, 29)
17
17
  end
18
18
 
19
+ it "should keep the same class as the receiver" do
20
+ c = Class.new(Date)
21
+ c.jd.<<(-10).should be_kind_of(c)
22
+ end
23
+
19
24
  it "should raise an error on non numeric parameters" do
20
25
  lambda { Date.civil(2007,2,27) << "hello" }.should raise_error(TypeError)
21
26
  lambda { Date.civil(2007,2,27) << Date.new }.should raise_error(TypeError)
@@ -14,6 +14,11 @@ describe "Date#-" do
14
14
  d.should == Date.civil(2007, 5 ,2)
15
15
  end
16
16
 
17
+ it "should keep the same class as the receiver" do
18
+ c = Class.new(Date)
19
+ c.jd.-(10).should be_kind_of(c)
20
+ end
21
+
17
22
  it "should be able to compute the different between two dates" do
18
23
  (Date.civil(2007,2,27) - Date.civil(2007,2,27)).should == 0
19
24
  (Date.civil(2007,2,27) - Date.civil(2007,2,26)).should == 1
@@ -13,6 +13,11 @@ ruby_version_is "1.9" do
13
13
  it "should handle a negative argument by subtracting days" do
14
14
  (Date.civil(2007,2,27).next_day(-2)).should == Date.civil(2007, 2, 25)
15
15
  end
16
+
17
+ it "should keep the same class as the receiver" do
18
+ c = Class.new(Date)
19
+ c.jd.next_day.should be_kind_of(c)
20
+ end
16
21
  end
17
22
 
18
23
  describe "Date#prev_day" do
@@ -27,6 +32,11 @@ ruby_version_is "1.9" do
27
32
  it "should handle a negative argument by adding days" do
28
33
  (Date.civil(2007,2,27).prev_day(-2)).should == Date.civil(2007, 3, 1)
29
34
  end
35
+
36
+ it "should keep the same class as the receiver" do
37
+ c = Class.new(Date)
38
+ c.jd.prev_day.should be_kind_of(c)
39
+ end
30
40
  end
31
41
 
32
42
  describe "Date#next_month" do
@@ -47,6 +57,11 @@ ruby_version_is "1.9" do
47
57
  (Date.civil(2008,1,31).next_month).should == Date.civil(2008, 2, 29)
48
58
  (Date.civil(2007,1,31).next_month(3)).should == Date.civil(2007, 4, 30)
49
59
  end
60
+
61
+ it "should keep the same class as the receiver" do
62
+ c = Class.new(Date)
63
+ c.jd.next_month.should be_kind_of(c)
64
+ end
50
65
  end
51
66
 
52
67
  describe "Date#prev_month" do
@@ -67,6 +82,11 @@ ruby_version_is "1.9" do
67
82
  (Date.civil(2008,3,31).prev_month).should == Date.civil(2008, 2, 29)
68
83
  (Date.civil(2007,3,31).prev_month(4)).should == Date.civil(2006, 11, 30)
69
84
  end
85
+
86
+ it "should keep the same class as the receiver" do
87
+ c = Class.new(Date)
88
+ c.jd.prev_month.should be_kind_of(c)
89
+ end
70
90
  end
71
91
 
72
92
  describe "Date#next_year" do
@@ -85,6 +105,11 @@ ruby_version_is "1.9" do
85
105
  it "should handle adding a year where the new date is not a valid date" do
86
106
  (Date.civil(2008,2,29).next_year).should == Date.civil(2009, 2, 28)
87
107
  end
108
+
109
+ it "should keep the same class as the receiver" do
110
+ c = Class.new(Date)
111
+ c.jd.next_year.should be_kind_of(c)
112
+ end
88
113
  end
89
114
 
90
115
  describe "Date#prev_year" do
@@ -103,6 +128,10 @@ ruby_version_is "1.9" do
103
128
  it "should handle adding a year where the new date is not a valid date" do
104
129
  (Date.civil(2008,2,29).prev_year).should == Date.civil(2007, 2, 28)
105
130
  end
106
- end
107
131
 
132
+ it "should keep the same class as the receiver" do
133
+ c = Class.new(Date)
134
+ c.jd.prev_year.should be_kind_of(c)
135
+ end
136
+ end
108
137
  end
@@ -25,6 +25,11 @@ describe "Date.ordinal" do
25
25
  lambda { Date.ordinal(2008, 367) }.should raise_error(ArgumentError)
26
26
  end
27
27
 
28
+ it "should keep the same class as the receiver" do
29
+ c = Class.new(Date)
30
+ c.ordinal.should be_kind_of(c)
31
+ end
32
+
28
33
  ruby_version_is "" ... "1.9" do
29
34
  it ".new2 should be the same as ordinal" do
30
35
  Date.new2(2008, 10).should == Date.ordinal(2008, 10)
@@ -57,6 +57,12 @@ describe "Date.parse" do
57
57
  Date.parse('2008-10-11', true, 1).should == Date.civil(2008, 10, 11)
58
58
  end
59
59
 
60
+ it "should keep the same class as the receiver" do
61
+ c = Class.new(Date)
62
+ c.parse.should be_kind_of(c)
63
+ c.parse('20081011').should be_kind_of(c)
64
+ end
65
+
60
66
  it "raises errors for invalid dates" do
61
67
  lambda { Date.parse("") }.should raise_error(ArgumentError)
62
68
  lambda { Date.parse("2009-02-29") }.should raise_error(ArgumentError)
@@ -84,5 +84,16 @@ ruby_version_is "1.9" do
84
84
  it ".xmlschema should parse an ISO8601 format" do
85
85
  Date.xmlschema("2009-01-02").should == Date.new(2009, 1, 2)
86
86
  end
87
+
88
+ it "should keep the same class as the receiver" do
89
+ c = Class.new(Date)
90
+ c.httpdate("Fri, 02 Jan 2009 00:00:00 GMT").should be_kind_of(c)
91
+ c.iso8601("2009-01-02").should be_kind_of(c)
92
+ c.jisx0301("H21.01.02").should be_kind_of(c)
93
+ c.rfc2822("Fri, 2 Jan 2009 00:00:00 +0000").should be_kind_of(c)
94
+ c.rfc822("Fri, 2 Jan 2009 00:00:00 +0000").should be_kind_of(c)
95
+ c.rfc3339("2009-01-02T00:00:00+00:00").should be_kind_of(c)
96
+ c.xmlschema("2009-01-02").should be_kind_of(c)
97
+ end
87
98
  end
88
99
  end
@@ -128,4 +128,10 @@ describe "Date#step" do
128
128
  count.should == 0
129
129
  end
130
130
 
131
+ it "should keep the same class as the receiver" do
132
+ c = Class.new(Date)
133
+ c.jd.step(c.jd + 2) do |d|
134
+ d.should be_kind_of(c)
135
+ end.should be_kind_of(c)
136
+ end
131
137
  end
@@ -22,6 +22,12 @@ describe "Date#strptime" do
22
22
  Date.strptime('2008-10-11', '%Y-%m-%d', 1).should == Date.civil(2008, 10, 11)
23
23
  end
24
24
 
25
+ it "should keep the same class as the receiver" do
26
+ c = Class.new(Date)
27
+ c.strptime.should be_kind_of(c)
28
+ c.strptime('20081011', '%Y%m%d').should be_kind_of(c)
29
+ end
30
+
25
31
  it "raises errors for invalid dates" do
26
32
  lambda { Date.strptime("") }.should raise_error(ArgumentError)
27
33
  lambda { Date.strptime("", "") }.should raise_error(ArgumentError)
@@ -14,6 +14,11 @@ describe "Date#succ" do
14
14
  ds.succ.should == Date.ordinal(2009, 1)
15
15
  end
16
16
 
17
+ it "should keep the same class as the receiver" do
18
+ c = Class.new(Date)
19
+ c.jd.succ.should be_kind_of(c)
20
+ end
21
+
17
22
  it "should be aliased as next" do
18
23
  Date.civil(2008, 10, 11).next.should == Date.civil(2008, 10, 12)
19
24
  end
@@ -12,4 +12,9 @@ describe "Date.today" do
12
12
  it ".today should have an optional sg value" do
13
13
  Date.today(1).should == Date.today
14
14
  end
15
+
16
+ it "should keep the same class as the receiver" do
17
+ c = Class.new(Date)
18
+ c.today.should be_kind_of(c)
19
+ end
15
20
  end
@@ -14,4 +14,11 @@ describe "Date#upto" do
14
14
  count.should == 13
15
15
  end
16
16
 
17
+
18
+ it "should keep the same class as the receiver" do
19
+ c = Class.new(Date)
20
+ c.jd.upto(c.jd + 2) do |d|
21
+ d.should be_kind_of(c)
22
+ end.should be_kind_of(c)
23
+ end
17
24
  end
@@ -17,6 +17,11 @@ describe "DateTime#>>" do
17
17
  d.should == DateTime.civil(2008, 4, 30)
18
18
  end
19
19
 
20
+ it "should keep the same class as the receiver" do
21
+ c = Class.new(DateTime)
22
+ c.jd.>>(10).should be_kind_of(c)
23
+ end
24
+
20
25
  it "should raise an error on non numeric parameters" do
21
26
  lambda { DateTime.civil(2007,2,27) >> "hello" }.should raise_error(TypeError)
22
27
  lambda { DateTime.civil(2007,2,27) >> DateTime.new }.should raise_error(TypeError)
@@ -26,6 +26,11 @@ describe "DateTime#+" do
26
26
  d.should == DateTime.civil(2007, 2, 16, 12)
27
27
  end
28
28
 
29
+ it "should keep the same class as the receiver" do
30
+ c = Class.new(DateTime)
31
+ c.jd.+(10).should be_kind_of(c)
32
+ end
33
+
29
34
  it "should raise an error on non numeric parameters" do
30
35
  lambda { DateTime.civil(2007,2,27) + :hello }.should raise_error
31
36
  lambda { DateTime.civil(2007,2,27) + "hello" }.should raise_error
@@ -139,4 +139,14 @@ describe "DateTime constructors" do
139
139
  DateTime.ordinal(2008, 1, 0, 0, 0, 0).should == DateTime.ordinal(2008, 1, 0, 0, 0, 0)
140
140
  DateTime.ordinal(2008, 1, 1, 1, 1, 0.5, 1).should == DateTime.ordinal(2008, 1, 1, 1, 1, 0.5)
141
141
  end
142
+
143
+ it "should keep the same class as the receiver" do
144
+ c = Class.new(DateTime)
145
+ c.jd.should be_kind_of(c)
146
+ c.civil.should be_kind_of(c)
147
+ c.commercial.should be_kind_of(c)
148
+ c.ordinal.should be_kind_of(c)
149
+ c.new!.should be_kind_of(c)
150
+ c.new.should be_kind_of(c)
151
+ end
142
152
  end