1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Memoize coerced TimeWithZone value in TimeWithZone#localtime.

This commit is contained in:
Ryan De Villa 2016-08-22 14:57:34 -04:00
parent fa9f1538f0
commit af054a5ae9

View file

@ -80,16 +80,10 @@ module ActiveSupport
# Returns a <tt>Time</tt> instance of the simultaneous time in the system timezone.
def localtime(utc_offset = nil)
utc.getlocal(utc_offset)
@localtime ||= utc.getlocal(utc_offset)
end
alias_method :getlocal, :localtime
def to_time_with_caching
@to_time ||= to_time_without_caching
end
alias_method :to_time_without_caching, :to_time
alias_method :to_time, :to_time_with_caching
# Returns true if the current time is within Daylight Savings Time for the
# specified time zone.
#