diff options
Diffstat (limited to 'spec/ruby/core/time/zone_spec.rb')
| -rw-r--r-- | spec/ruby/core/time/zone_spec.rb | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/spec/ruby/core/time/zone_spec.rb b/spec/ruby/core/time/zone_spec.rb index 907ccf9f4b..2cb3c5e7bb 100644 --- a/spec/ruby/core/time/zone_spec.rb +++ b/spec/ruby/core/time/zone_spec.rb @@ -6,7 +6,7 @@ describe "Time#zone" do with_timezone("America/New_York") do Time.new(2001, 1, 1, 0, 0, 0).zone.should == "EST" Time.new(2001, 7, 1, 0, 0, 0).zone.should == "EDT" - %w[EST EDT].should include Time.now.zone + %w[EST EDT].should.include? Time.now.zone end end end @@ -29,7 +29,7 @@ describe "Time#zone" do t = Time.new(2005, 2, 27, 22, 50, 0, -3600) with_timezone("America/New_York") do - t.getlocal("+05:00").zone.should be_nil + t.getlocal("+05:00").zone.should == nil end end @@ -52,14 +52,35 @@ describe "Time#zone" do end it "doesn't raise errors for a Time with a fixed offset" do - -> { - Time.new(2001, 1, 1, 0, 0, 0, "+05:00").zone - }.should_not raise_error + Time.new(2001, 1, 1, 0, 0, 0, "+05:00").zone.should == nil end end it "returns UTC when called on a UTC time" do Time.now.utc.zone.should == "UTC" + Time.now.gmtime.zone.should == "UTC" + Time.now.getgm.zone.should == "UTC" + Time.now.getutc.zone.should == "UTC" + Time.utc(2022).zone.should == "UTC" + Time.new(2022, 1, 1, 0, 0, 0, "UTC").zone.should == "UTC" + Time.new(2022, 1, 1, 0, 0, 0, "Z").zone.should == "UTC" + Time.now.localtime("UTC").zone.should == "UTC" + Time.now.localtime("Z").zone.should == "UTC" + Time.at(Time.now, in: 'UTC').zone.should == "UTC" + Time.at(Time.now, in: 'Z').zone.should == "UTC" + + Time.new(2022, 1, 1, 0, 0, 0, "-00:00").zone.should == "UTC" + Time.now.localtime("-00:00").zone.should == "UTC" + Time.at(Time.now, in: '-00:00').zone.should == "UTC" + + Time.new(2022, 1, 1, 0, 0, 0, in: "UTC").zone.should == "UTC" + Time.new(2022, 1, 1, 0, 0, 0, in: "Z").zone.should == "UTC" + + Time.now(in: 'UTC').zone.should == "UTC" + Time.now(in: 'Z').zone.should == "UTC" + + Time.at(Time.now, in: 'UTC').zone.should == "UTC" + Time.at(Time.now, in: 'Z').zone.should == "UTC" end platform_is_not :aix, :windows do |
