diff options
-rw-r--r-- | spec/ruby/library/datetime/to_time_spec.rb | 13 | ||||
-rw-r--r-- | spec/ruby/library/time/to_datetime_spec.rb | 13 |
2 files changed, 26 insertions, 0 deletions
diff --git a/spec/ruby/library/datetime/to_time_spec.rb b/spec/ruby/library/datetime/to_time_spec.rb index a03ab67867..88a7aaa739 100644 --- a/spec/ruby/library/datetime/to_time_spec.rb +++ b/spec/ruby/library/datetime/to_time_spec.rb @@ -18,6 +18,19 @@ describe "DateTime#to_time" do time.sec.should == 59 end + version_is(Date::VERSION, '3.2.3') do + it "returns a Time representing the same instant before Gregorian" do + datetime = DateTime.civil(1582, 10, 4, 23, 58, 59) + time = datetime.to_time.utc + time.year.should == 1582 + time.month.should == 10 + time.day.should == 14 + time.hour.should == 23 + time.min.should == 58 + time.sec.should == 59 + end + end + it "preserves the same time regardless of local time or zone" do date = DateTime.new(2012, 12, 24, 12, 23, 00, '+03:00') diff --git a/spec/ruby/library/time/to_datetime_spec.rb b/spec/ruby/library/time/to_datetime_spec.rb index 2c1e060f0f..c5561535b2 100644 --- a/spec/ruby/library/time/to_datetime_spec.rb +++ b/spec/ruby/library/time/to_datetime_spec.rb @@ -13,6 +13,19 @@ describe "Time#to_datetime" do datetime.sec.should == 59 end + version_is(Date::VERSION, '3.2.3') do + it "returns a DateTime representing the same instant before Gregorian" do + time = Time.utc(1582, 10, 14, 23, 58, 59) + datetime = time.to_datetime + datetime.year.should == 1582 + datetime.month.should == 10 + datetime.day.should == 4 + datetime.hour.should == 23 + datetime.min.should == 58 + datetime.sec.should == 59 + end + end + it "roundtrips" do time = Time.utc(3, 12, 31, 23, 58, 59) datetime = time.to_datetime |