class method
self.at_with_coercion
Ruby on Rails edge
Since v3.2.22.5Signature
self.at_with_coercion(time_or_number, *args, **kwargs)
Layers additional behavior on Time.at so that ActiveSupport::TimeWithZone and DateTime instances can be used when called with a single argument
Parameters
-
time_or_numberreq -
argsrest -
kwargskeyrest
Source
# File activesupport/lib/active_support/core_ext/time/calculations.rb, line 48
def at_with_coercion(time_or_number, *args, **kwargs)
return at_without_coercion(time_or_number, *args, **kwargs) unless args.empty? && kwargs.empty?
case time_or_number
when ActiveSupport::TimeWithZone
at_without_coercion(time_or_number.to_r).getlocal
when DateTime
at_without_coercion(time_or_number.to_i + time_or_number.sec_fraction).getlocal
else
at_without_coercion(time_or_number)
end
end
Defined in activesupport/lib/active_support/core_ext/time/calculations.rb line 48
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Time