Skip to content

Commit

Permalink
Make Time friendly to Ractor
Browse files Browse the repository at this point in the history
  • Loading branch information
kirs authored and nobu committed Jan 22, 2021
1 parent 6b8cc47 commit c784e4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/time.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true
# shareable_constant_value: literal

require 'date'

Expand Down
7 changes: 7 additions & 0 deletions test/test_time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ def test_rfc2822
assert_equal(true, t.utc?)
end

if defined?(Ractor)
def test_rfc2822_ractor
actual = Ractor.new { Time.rfc2822("Fri, 21 Nov 1997 09:55:06 -0600") }.take
assert_equal(Time.utc(1997, 11, 21, 9, 55, 6) + 6 * 3600, actual)
end
end

def test_encode_rfc2822
t = Time.utc(1)
assert_equal("Mon, 01 Jan 0001 00:00:00 -0000", t.rfc2822)
Expand Down

0 comments on commit c784e4f

Please sign in to comment.