aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-08 04:03:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-08 04:03:32 +0000
commita75c56eaf0cfa5b8a016329a2ef1f350ab7de779 (patch)
treecb5a947db7decdc303dda63630b4191741c2884d /spec
parente5d9e98fdc6a4712d7c5642b5cc9436aab5af676 (diff)
downloadruby-a75c56eaf0cfa5b8a016329a2ef1f350ab7de779.tar.gz
Timezone at Time#+ and Time#-
* time.c (time_add): support for Timezone. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec')
-rw-r--r--spec/ruby/core/time/plus_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/ruby/core/time/plus_spec.rb b/spec/ruby/core/time/plus_spec.rb
index 0cf0d11a74..0861e9c9f6 100644
--- a/spec/ruby/core/time/plus_spec.rb
+++ b/spec/ruby/core/time/plus_spec.rb
@@ -47,6 +47,19 @@ describe "Time#+" do
(Time.new(2012, 1, 1, 0, 0, 0, 3600) + 10).utc_offset.should == 3600
end
+ ruby_version_is "2.6" do
+ it "returns a time with the same timezone as self" do
+ zone = mock("timezone")
+ zone.should_receive(:local_to_utc).and_return(Time.utc(2012, 1, 1, 6, 30, 0))
+ zone.should_receive(:utc_to_local).and_return(Time.utc(2012, 1, 1, 12, 0, 10))
+ t = Time.new(2012, 1, 1, 12, 0, 0, zone) + 10
+ t.zone.should == zone
+ t.utc_offset.should == 19800
+ t.to_a[0, 6].should == [10, 0, 12, 1, 1, 2012]
+ t.should == Time.utc(2012, 1, 1, 6, 30, 10)
+ end
+ end
+
it "does not return a subclass instance" do
c = Class.new(Time)
x = c.now + 1