Skip to content

Commit 82ca639

Browse files
committed
iso8601 should have the specs and #xmlschema be the alias
1 parent 9513cf7 commit 82ca639

4 files changed

Lines changed: 32 additions & 32 deletions

File tree

core/time/iso8601_spec.rb

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,32 @@
22

33
describe "Time#iso8601" do
44
ruby_version_is "3.4" do
5-
it "is an alias of Time#xmlschema" do
6-
Time.instance_method(:iso8601).should == Time.instance_method(:xmlschema)
5+
it "generates ISO-8601 strings in Z for UTC times" do
6+
t = Time.utc(1985, 4, 12, 23, 20, 50, 521245)
7+
t.iso8601.should == "1985-04-12T23:20:50Z"
8+
t.iso8601(2).should == "1985-04-12T23:20:50.52Z"
9+
t.iso8601(9).should == "1985-04-12T23:20:50.521245000Z"
10+
end
11+
12+
it "generates ISO-8601 string with timezone offset for non-UTC times" do
13+
t = Time.new(1985, 4, 12, 23, 20, 50, "+02:00")
14+
t.iso8601.should == "1985-04-12T23:20:50+02:00"
15+
t.iso8601(2).should == "1985-04-12T23:20:50.00+02:00"
16+
end
17+
18+
it "year is always at least 4 digits" do
19+
t = Time.utc(12, 4, 12)
20+
t.iso8601.should == "0012-04-12T00:00:00Z"
21+
end
22+
23+
it "year can be more than 4 digits" do
24+
t = Time.utc(40_000, 4, 12)
25+
t.iso8601.should == "40000-04-12T00:00:00Z"
26+
end
27+
28+
it "year can be negative" do
29+
t = Time.utc(-2000, 4, 12)
30+
t.iso8601.should == "-2000-04-12T00:00:00Z"
731
end
832
end
933
end

core/time/xmlschema_spec.rb

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,8 @@
22

33
describe "Time#xmlschema" do
44
ruby_version_is "3.4" do
5-
it "generates ISO-8601 strings in Z for UTC times" do
6-
t = Time.utc(1985, 4, 12, 23, 20, 50, 521245)
7-
t.xmlschema.should == "1985-04-12T23:20:50Z"
8-
t.xmlschema(2).should == "1985-04-12T23:20:50.52Z"
9-
t.xmlschema(9).should == "1985-04-12T23:20:50.521245000Z"
10-
end
11-
12-
it "generates ISO-8601 string with timezone offset for non-UTC times" do
13-
t = Time.new(1985, 4, 12, 23, 20, 50, "+02:00")
14-
t.xmlschema.should == "1985-04-12T23:20:50+02:00"
15-
t.xmlschema(2).should == "1985-04-12T23:20:50.00+02:00"
16-
end
17-
18-
it "year is always at least 4 digits" do
19-
t = Time.utc(12, 4, 12)
20-
t.xmlschema.should == "0012-04-12T00:00:00Z"
21-
end
22-
23-
it "year can be more than 4 digits" do
24-
t = Time.utc(40_000, 4, 12)
25-
t.xmlschema.should == "40000-04-12T00:00:00Z"
26-
end
27-
28-
it "year can be negative" do
29-
t = Time.utc(-2000, 4, 12)
30-
t.xmlschema.should == "-2000-04-12T00:00:00Z"
5+
it "is an alias of Time#iso8601" do
6+
Time.instance_method(:xmlschema).should == Time.instance_method(:iso8601)
317
end
328
end
339
end

library/datetime/iso8601_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@
66
end
77

88
describe "DateTime#iso8601" do
9-
it "needs to be reviewed for spec completeness"
9+
it "is an alias of DateTime#isoxmlschema8601" do
10+
DateTime.instance_method(:iso8601).should == DateTime.instance_method(:xmlschema)
11+
end
1012
end

library/datetime/xmlschema_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@
66
end
77

88
describe "DateTime#xmlschema" do
9-
it "is an alias of DateTime#iso8601" do
10-
DateTime.instance_method(:xmlschema).should == DateTime.instance_method(:iso8601)
11-
end
9+
it "needs to be reviewed for spec completeness"
1210
end

0 commit comments

Comments
 (0)