mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
TimeWithZone#advance: leverage Hash#values_at and non-block form of #any? for a little less line noise, and a slight speedup (thanks raggi and Roman2K)
This commit is contained in:
@@ -230,7 +230,7 @@ module ActiveSupport
|
||||
def advance(options)
|
||||
# If we're advancing a value of variable length (i.e., years, weeks, months, days), advance from #time,
|
||||
# otherwise advance from #utc, for accuracy when moving across DST boundaries
|
||||
if options.any? {|k,v| [:years, :weeks, :months, :days].include? k}
|
||||
if options.values_at(:years, :weeks, :months, :days).any?
|
||||
method_missing(:advance, options)
|
||||
else
|
||||
utc.advance(options).in_time_zone(time_zone)
|
||||
|
||||
Reference in New Issue
Block a user