mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[Bug #18946] New tests for fixed Time/DateTime conversions
This commit is contained in:
parent
e0dfa5967e
commit
43239b23b4
2 changed files with 26 additions and 0 deletions
|
@ -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')
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue