diff options
author | Hiroshi SHIBATA <[email protected]> | 2023-03-29 13:29:08 +0900 |
---|---|---|
committer | usa <[email protected]> | 2023-03-30 19:49:08 +0900 |
commit | 53a7cee6850bd0d5999fcb56471f0a507222f486 (patch) | |
tree | a7656ffb2b00ecc6eb9eb0b1d6117e65aca99613 | |
parent | 2d99ef4f74e13de352ffd867ffe7308f78d7418e (diff) |
Merge Time-0.1.1
-rw-r--r-- | lib/time.gemspec | 4 | ||||
-rw-r--r-- | lib/time.rb | 4 | ||||
-rw-r--r-- | test/test_time.rb | 9 |
3 files changed, 12 insertions, 5 deletions
diff --git a/lib/time.gemspec b/lib/time.gemspec index 040b9f34cf..be6de35c99 100644 --- a/lib/time.gemspec +++ b/lib/time.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = "time" - spec.version = "0.1.0" + spec.version = "0.1.1" spec.authors = ["Tanaka Akira"] spec.email = ["[email protected]"] @@ -19,6 +19,4 @@ Gem::Specification.new do |spec| spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - - spec.add_dependency "date" end diff --git a/lib/time.rb b/lib/time.rb index 625c2c87bb..8af482cb68 100644 --- a/lib/time.rb +++ b/lib/time.rb @@ -506,8 +506,8 @@ class Time (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+ (\d{2,})\s+ (\d{2})\s* - :\s*(\d{2})\s* - (?::\s*(\d{2}))?\s+ + :\s*(\d{2}) + (?:\s*:\s*(\d\d))?\s+ ([+-]\d{4}| UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|[A-IK-Z])/ix =~ date # Since RFC 2822 permit comments, the regexp has no right anchor. diff --git a/test/test_time.rb b/test/test_time.rb index ca20788aac..4f11048596 100644 --- a/test/test_time.rb +++ b/test/test_time.rb @@ -62,6 +62,15 @@ class TestTimeExtension < Test::Unit::TestCase # :nodoc: assert_equal(true, t.utc?) end + def test_rfc2822_nonlinear + pre = ->(n) {"0 Feb 00 00 :00" + " " * n} + assert_linear_performance([100, 500, 5000, 50_000], pre: pre) do |s| + assert_raise(ArgumentError) do + Time.rfc2822(s) + end + end + end + def test_encode_rfc2822 t = Time.utc(1) assert_equal("Mon, 01 Jan 0001 00:00:00 -0000", t.rfc2822) |