Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Gem::Cooldown.parse_created_at
parse_created_at(value)
lib/rubygems/cooldown.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/cooldown.rb, line 120
def self.parse_created_at(value)
return unless value.is_a?(String) && value.match?(FOUR_DIGIT_YEAR)
require "time"
begin
Time.iso8601(value.match?(TIME_ZONE_SUFFIX) ? value : "#{value}Z")
rescue ArgumentError
nil
end
end
Parses a created_at timestamp from the compact index. A timestamp without a time zone offset is read as UTC, because reading it as local time would shift the cooldown window by the environment’s offset. Returns nil for anything unparsable, including a year outside four digits, so the cooldown fails open.