Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ def rfc3339(time)
[T\s]
(\d\d):(\d\d):(\d\d)
(\.\d+)?
(Z|[+-]\d\d(?::?\d\d)?)
(Z|[+-]\d\d:?\d\d)
\s*\z/ix
_xmlschema(pattern, time)
end
Expand Down
7 changes: 6 additions & 1 deletion test/test_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ def subtest_xmlschema_alias(method)
s = "1996-12-19T16:39:57-08:00"
assert_equal(t, Time.__send__(method, s))
assert_equal(t, Time.__send__(method, s.sub(/:(?=00\z)/, '')))
assert_equal(t, Time.__send__(method, s.sub(/:00\z/, '')))
if method == :rfc3339
assert_raise(ArgumentError) { Time.rfc3339(s.sub(/:00\z/, '')) }
else
assert_equal(t, Time.__send__(method, s.sub(/:00\z/, '')))
end
# There is no way to generate time string with arbitrary timezone.
s = "1996-12-20T00:39:57Z"
assert_equal(t, Time.__send__(method, s))
Expand Down Expand Up @@ -182,6 +186,7 @@ def subtest_xmlschema(method)
[Time.local(2000, 1, 1, 12, 0, 0), "2000-01-01T12:00:00"],
[Time.local(2000, 1, 16, 12, 0, 0), "2000-01-16T12:00:00"],
[Time.local(2000, 1, 16, 0, 0, 0), "2000-01-16T00:00:00"],
[Time.utc(2000, 1, 16, 0, 0, 0), "2000-01-16T00:00:00+00"],
]
local_times.each do |expected, time|
if method == :rfc3339
Expand Down