|
4 | 4 | describe "Time.now" do
|
5 | 5 | it_behaves_like :time_now, :now
|
6 | 6 |
|
7 |
| - describe ":in keyword argument" do |
8 |
| - it "could be UTC offset as a String in '+HH:MM or '-HH:MM' format" do |
9 |
| - time = Time.now(in: "+05:00") |
| 7 | + ruby_version_is '3.1' do # https://bugs.ruby-lang.org/issues/17485 |
| 8 | + describe ":in keyword argument" do |
| 9 | + it "could be UTC offset as a String in '+HH:MM or '-HH:MM' format" do |
| 10 | + time = Time.now(in: "+05:00") |
10 | 11 |
|
11 |
| - time.utc_offset.should == 5*60*60 |
12 |
| - time.zone.should == nil |
| 12 | + time.utc_offset.should == 5*60*60 |
| 13 | + time.zone.should == nil |
13 | 14 |
|
14 |
| - time = Time.now(in: "-09:00") |
| 15 | + time = Time.now(in: "-09:00") |
15 | 16 |
|
16 |
| - time.utc_offset.should == -9*60*60 |
17 |
| - time.zone.should == nil |
18 |
| - end |
| 17 | + time.utc_offset.should == -9*60*60 |
| 18 | + time.zone.should == nil |
| 19 | + end |
19 | 20 |
|
20 |
| - it "could be UTC offset as a number of seconds" do |
21 |
| - time = Time.now(in: 5*60*60) |
| 21 | + it "could be UTC offset as a number of seconds" do |
| 22 | + time = Time.now(in: 5*60*60) |
22 | 23 |
|
23 |
| - time.utc_offset.should == 5*60*60 |
24 |
| - time.zone.should == nil |
| 24 | + time.utc_offset.should == 5*60*60 |
| 25 | + time.zone.should == nil |
25 | 26 |
|
26 |
| - time = Time.now(in: -9*60*60) |
| 27 | + time = Time.now(in: -9*60*60) |
27 | 28 |
|
28 |
| - time.utc_offset.should == -9*60*60 |
29 |
| - time.zone.should == nil |
30 |
| - end |
| 29 | + time.utc_offset.should == -9*60*60 |
| 30 | + time.zone.should == nil |
| 31 | + end |
31 | 32 |
|
32 |
| - it "could be a timezone object" do |
33 |
| - zone = TimeSpecs::TimezoneWithName.new(name: "Asia/Colombo") |
34 |
| - time = Time.now(in: zone) |
| 33 | + it "could be a timezone object" do |
| 34 | + zone = TimeSpecs::TimezoneWithName.new(name: "Asia/Colombo") |
| 35 | + time = Time.now(in: zone) |
35 | 36 |
|
36 |
| - time.utc_offset.should == 5*3600+30*60 |
37 |
| - time.zone.should == zone |
| 37 | + time.utc_offset.should == 5*3600+30*60 |
| 38 | + time.zone.should == zone |
38 | 39 |
|
39 |
| - zone = TimeSpecs::TimezoneWithName.new(name: "PST") |
40 |
| - time = Time.now(in: zone) |
| 40 | + zone = TimeSpecs::TimezoneWithName.new(name: "PST") |
| 41 | + time = Time.now(in: zone) |
41 | 42 |
|
42 |
| - time.utc_offset.should == -9*60*60 |
43 |
| - time.zone.should == zone |
44 |
| - end |
| 43 | + time.utc_offset.should == -9*60*60 |
| 44 | + time.zone.should == zone |
| 45 | + end |
45 | 46 |
|
46 |
| - it "raises ArgumentError if format is invalid" do |
47 |
| - -> { Time.now(in: "+09:99") }.should raise_error(ArgumentError) |
48 |
| - -> { Time.now(in: "ABC") }.should raise_error(ArgumentError) |
| 47 | + it "raises ArgumentError if format is invalid" do |
| 48 | + -> { Time.now(in: "+09:99") }.should raise_error(ArgumentError) |
| 49 | + -> { Time.now(in: "ABC") }.should raise_error(ArgumentError) |
| 50 | + end |
49 | 51 | end
|
50 | 52 | end
|
51 | 53 | end
|
0 commit comments