Skip to content

Commit b126827

Browse files
committed
Require colon in timezone offset for Time.rfc3339
Fixes #77
1 parent 95ab5fa commit b126827

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

lib/time.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ def rfc3339(time)
660660
[T\s]
661661
(\d\d):(\d\d):(\d\d)
662662
(\.\d+)?
663-
(Z|[+-]\d\d:?\d\d)
663+
(Z|[+-]\d\d:\d\d)
664664
\s*\z/ix
665665
_xmlschema(pattern, time)
666666
end

test/test_time.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,11 @@ def subtest_xmlschema_alias(method)
123123
t = Time.utc(1996, 12, 20, 0, 39, 57)
124124
s = "1996-12-19T16:39:57-08:00"
125125
assert_equal(t, Time.__send__(method, s))
126-
assert_equal(t, Time.__send__(method, s.sub(/:(?=00\z)/, '')))
127126
if method == :rfc3339
127+
assert_raise(ArgumentError) { Time.rfc3339(s.sub(/:(?=00\z)/, '')) }
128128
assert_raise(ArgumentError) { Time.rfc3339(s.sub(/:00\z/, '')) }
129129
else
130+
assert_equal(t, Time.__send__(method, s.sub(/:(?=00\z)/, '')))
130131
assert_equal(t, Time.__send__(method, s.sub(/:00\z/, '')))
131132
end
132133
# There is no way to generate time string with arbitrary timezone.

0 commit comments

Comments
 (0)